| 8 | flush?: boolean |
| 9 | } |
| 10 | export function ContentCode(props: Props) { |
| 11 | const [html] = createResource( |
| 12 | () => [props.code, props.lang], |
| 13 | async ([code, lang]) => { |
| 14 | // TODO: For testing delays |
| 15 | // await new Promise((resolve) => setTimeout(resolve, 3000)) |
| 16 | return (await codeToHtml(code || "", { |
| 17 | lang: lang && lang in bundledLanguages ? lang : "text", |
| 18 | themes: { |
| 19 | light: "github-light", |
| 20 | dark: "github-dark", |
| 21 | }, |
| 22 | })) as string |
| 23 | }, |
| 24 | ) |
| 25 | return ( |
| 26 | <Suspense> |
| 27 | <div innerHTML={html()} class={style.root} data-flush={props.flush === true ? true : undefined} /> |
| 28 | </Suspense> |
| 29 | ) |
| 30 | } |