MCPcopy
hub / github.com/code-hike/codehike / Demo

Function Demo

apps/web/components/demo.tsx:6–57  ·  view source on GitHub ↗
({
  name,
  children,
  className,
  content = "content.md",
}: {
  name: string
  content?: string
  children: React.ReactNode
  className?: string
})

Source from the content-addressed store, hash-verified

4import { cn } from "../lib/utils"
5
6export async function Demo({
7 name,
8 children,
9 className,
10 content = "content.md",
11}: {
12 name: string
13 content?: string
14 children: React.ReactNode
15 className?: string
16}) {
17 const value = await fs.promises.readFile(
18 path.join(process.cwd(), "demos", name, content),
19 "utf-8",
20 )
21
22 const usage = (
23 <Code
24 className="min-h-full flex flex-col my-0 max-h-full"
25 codeblock={{
26 value,
27 lang: "mdx",
28 meta: `${content} -pwc`,
29 }}
30 />
31 )
32
33 const { default: Page } = await import(`@/demos/${name}/page`)
34
35 const preview = (
36 <div className="min-w-0 rounded flex-1 bg-blue-900/80 bg-[url(/dark-grid.svg)] p-3 flex flex-col overflow-hidden prose-invert">
37 <Page />
38 {children && (
39 <div className="mt-auto text-center text-white font-light pt-2">
40 {children}
41 </div>
42 )}
43 </div>
44 )
45
46 return (
47 <div
48 className={cn(
49 "flex gap-2 flex-wrap [&>*]:flex-1 [&>*]:min-w-72",
50 className,
51 )}
52 >
53 <div className="min-w-0 flex-1 max-h-full">{usage}</div>
54 {preview}
55 </div>
56 )
57}

Callers

nothing calls this directly

Calls 1

cnFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…