import { type FileContents, File, FileOptions, LineAnnotation } from "@pierre/precision-diffs" import { ComponentProps, createEffect, splitProps } from "solid-js" export type CodeProps = FileOptions & { file: FileContents annotations?: LineAnnotation[] class?: string classList?: ComponentProps<"div">["classList"] } export function Code(props: CodeProps) { let container!: HTMLDivElement const [local, others] = splitProps(props, ["file", "class", "classList", "annotations"]) const file = () => local.file createEffect(() => { const instance = new File({ theme: { dark: "oc-1-dark", light: "oc-1-light" }, // or any Shiki theme overflow: "wrap", // or 'scroll' themeType: "system", // 'system', 'light', or 'dark' disableLineNumbers: false, // optional // lang: 'typescript', // optional - auto-detected from filename if not provided ...others, }) instance.render({ file: file(), lineAnnotations: local.annotations, containerWrapper: container, }) }) return (
) }