| 1 | /** |
| 2 | * Syntax-highlighted blob rendering via `@pierre/diffs`' `<File>`. |
| 3 | * |
| 4 | * `React.lazy`-loaded from `Repo.tsx`'s BlobTab so the diffs+shiki |
| 5 | * runtime stays out of the initial bundle. The filename drives language |
| 6 | * detection (by extension); the built-in header is disabled — the tab |
| 7 | * keeps its own lines/bytes bar. |
| 8 | */ |
| 9 | import type { FileContents } from "@pierre/diffs"; |
| 10 | import { File } from "@pierre/diffs/react"; |
| 11 | import { useMemo } from "react"; |
| 12 | import { useFileOptions } from "../diff.tsx"; |
| 13 | |
| 14 | const FileView = ({ name, text }: { name: string; text: string }) => { |
| 15 | const file = useMemo<FileContents>( |
| 16 | () => ({ name, contents: text }), |
| 17 | [name, text], |
| 18 | ); |
| 19 | const options = useFileOptions(); |
| 20 | return <File file={file} options={options} />; |
| 21 | }; |
| 22 | |
| 23 | export default FileView; |