add rebrand landing page (#211)
This commit is contained in:
36
packages/ui/src/code-block.tsx
Normal file
36
packages/ui/src/code-block.tsx
Normal file
@@ -0,0 +1,36 @@
|
||||
import { BundledLanguage, codeToHast } from "shiki";
|
||||
import { toJsxRuntime } from "hast-util-to-jsx-runtime";
|
||||
import { Fragment } from "react";
|
||||
import { jsx, jsxs } from "react/jsx-runtime";
|
||||
import { cn } from "../lib/utils";
|
||||
|
||||
interface Props {
|
||||
children: string;
|
||||
lang: BundledLanguage;
|
||||
className?: string;
|
||||
}
|
||||
|
||||
export async function CodeBlock(props: Props) {
|
||||
const out = await codeToHast(props.children, {
|
||||
lang: props.lang,
|
||||
themes: {
|
||||
dark: "catppuccin-mocha",
|
||||
light: "catppuccin-latte",
|
||||
},
|
||||
});
|
||||
|
||||
return toJsxRuntime(out, {
|
||||
Fragment,
|
||||
jsx,
|
||||
jsxs,
|
||||
components: {
|
||||
// your custom `pre` element
|
||||
pre: (nodeProps) => (
|
||||
<pre
|
||||
{...nodeProps}
|
||||
className={cn(nodeProps.className, props.className)}
|
||||
/>
|
||||
),
|
||||
},
|
||||
}) as React.JSX.Element;
|
||||
}
|
Reference in New Issue
Block a user