/
Alex_Ural
/
opencode
Обзор
Документация
Войти
/
Alex_Ural
/
opencode
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
dev
packages/web/src/components/share/content-code.tsx
30 строк
851 B
Adam
wip(docs): i18n (#12681)
09 фев 2026, 20:34
Не верифицирован
09 фев 2026, 20:34
dc53086
Код
Авторство
О чём код?
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> ) }