({
path,
title,
}: {
path: string
title?: string
})
| 15 | * @example `<CodeGroupFromFile title="filename" path="src/showcase/..." />` |
| 16 | */ |
| 17 | export 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 | } |
nothing calls this directly
no test coverage detected