GHHG10's picture
download
raw
851 Bytes
import { codeToHtml, bundledLanguages } from "shiki"
import { createResource, Suspense } from "solid-js"
import style from "./content-code.module.css"
interface Props {
code: string
lang?: string
flush?: boolean
}
export function ContentCode(props: Props) {
const [html] = createResource(
() => [props.code, props.lang],
async ([code, lang]) => {
// TODO: For testing delays
// await new Promise((resolve) => setTimeout(resolve, 3000))
return (await codeToHtml(code || "", {
lang: lang && lang in bundledLanguages ? lang : "text",
themes: {
light: "github-light",
dark: "github-dark",
},
})) as string
},
)
return (
<Suspense>
<div innerHTML={html()} class={style.root} data-flush={props.flush === true ? true : undefined} />
</Suspense>
)
}

Xet Storage Details

Size:
851 Bytes
·
Xet hash:
cf947107523886179d87f8ddd5380122e00d4cec55f812e269c0190d401575bc

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.