MCPcopy Create free account
hub / github.com/SyntaxUI/syntaxui / CodeGroupFromFile

Function CodeGroupFromFile

src/components/code/CodeGroupFromFile.tsx:17–39  ·  view source on GitHub ↗
({
  path,
  title,
}: {
  path: string
  title?: string
})

Source from the content-addressed store, hash-verified

15 * @example `<CodeGroupFromFile title="filename" path="src/showcase/..." />`
16 */
17export default function CodeGroupFromFile({
18 path,
19 title,
20}: {
21 path: string
22 title?: string
23}) {
24 const [code, setCode] = useState('')
25 useEffect(() => {
26 const fetchCode = async () => {
27 const code = await readFile(path)
28 setCode(code)
29 }
30 fetchCode()
31 }, [path])
32
33 const lang = path.split('.').pop() ?? ''
34 return (
35 <CodeGroup title={title}>
36 <Code code={code} language={lang} />
37 </CodeGroup>
38 )
39}

Callers

nothing calls this directly

Calls 1

fetchCodeFunction · 0.85

Tested by

no test coverage detected