mirror of
https://github.com/aljazceru/opencode.git
synced 2025-12-22 10:14:22 +01:00
v2 message format and upgrade to ai sdk v5 (#743)
Co-authored-by: GitHub Action <action@github.com> Co-authored-by: Liang-Shih Lin <liangshihlin@proton.me> Co-authored-by: Dominik Engelhardt <dominikengelhardt@ymail.com> Co-authored-by: Jay V <air@live.ca> Co-authored-by: adamdottv <2363879+adamdottv@users.noreply.github.com>
This commit is contained in:
32
packages/web/src/components/share/content-code.tsx
Normal file
32
packages/web/src/components/share/content-code.tsx
Normal file
@@ -0,0 +1,32 @@
|
||||
import { type JSX, splitProps, createResource, Suspense } from "solid-js"
|
||||
import { codeToHtml } from "shiki"
|
||||
import style from "./content-code.module.css"
|
||||
import { transformerNotationDiff } from "@shikijs/transformers"
|
||||
|
||||
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 || "text",
|
||||
themes: {
|
||||
light: "github-light",
|
||||
dark: "github-dark",
|
||||
},
|
||||
transformers: [transformerNotationDiff()],
|
||||
})) as string
|
||||
},
|
||||
)
|
||||
return (
|
||||
<Suspense>
|
||||
<div innerHTML={html()} class={style.root} data-flush={props.flush === true ? true : undefined} />
|
||||
</Suspense>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user