'use client' import Link from 'next/link' import { useState, type PropsWithChildren } from 'react' import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from 'ui' export function CodeSampleWrapper({ children, /** * A GitHub URL to the source code file. */ source: _source, }: PropsWithChildren<{ source: string | URL | (string | URL)[] }>) { const source = Array.isArray(_source) ? _source : [_source] if (source.length === 1) { return {children} } if (source.length > 1) { return {children} } return <>{children} } function MultipleSources({ children, sources }: PropsWithChildren<{ sources: (string | URL)[] }>) { return ( <> {children} {sources.map((source) => ( window.open(source.toString(), '_blank', 'noopener noreferrer')} > ...{source.toString().split('/').slice(-2).join('/')} ))} ) } function SingleSource({ children, source }: PropsWithChildren<{ source: string | URL }>) { return ( <> {children} View source ) }