'use client'
import Link from 'next/link'
import { useState, type PropsWithChildren } from 'react'
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from 'ui'
import { Admonition } from 'ui-patterns/admonition'
export function CodeSampleDummy() {
return (
The $CodeSample directive with external repos is not supported in local
development because it relies on a GitHub API key. Please check the preview site to see the
final 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
>
)
}