diff --git a/frontend/src/components/Header.tsx b/frontend/src/components/Header.tsx index 16ec2ef..d83526d 100644 --- a/frontend/src/components/Header.tsx +++ b/frontend/src/components/Header.tsx @@ -52,7 +52,10 @@ export default function Header({ theme }: HeaderProps) {
+ {children}
+
+ );
+ }
+
+ return (
+
+ {children}
+
+ );
+ },
+
+ pre({ children }: ComponentPropsWithoutRef<"pre">): ReactElement {
+ const codeChild = Array.isArray(children) ? children[0] : children;
+
+ let lang = "";
+ let code = "";
+
+ if (
+ codeChild &&
+ typeof codeChild === "object" &&
+ "props" in codeChild
+ ) {
+ const el = codeChild as {
+ props: { className?: string; children?: string };
+ };
+ const cls = el.props?.className;
+ const match = cls?.match(/language-(\w+)/);
+ if (match) lang = match[1];
+ if (typeof el.props?.children === "string") {
+ code = el.props.children;
+ }
+ }
+
+ const highlighted =
+ lang && code
+ ? highlighter.codeToHtml(code, {
+ lang,
+ themes: {
+ dark: "catppuccin-macchiato",
+ light: "catppuccin-latte",
+ },
+ defaultColor: false,
+ })
+ : null;
+
+ if (highlighted) {
+ return (
+
+ {children}
+
+ {children}
; + }, + + ul({ children }: ComponentPropsWithoutRef<"ul">): ReactElement { + return+ {children} ++ ); + }, + + table({ children }: ComponentPropsWithoutRef<"table">): ReactElement { + return ( +
- {children}
-
- );
- }
-
- return (
-
- {children}
-
- );
- },
-
- pre({
- children,
- }: ComponentPropsWithoutRef<"pre">): ReactElement {
- const codeChild = Array.isArray(children)
- ? children[0]
- : children;
-
- let lang = "";
- let code = "";
-
- if (
- codeChild &&
- typeof codeChild === "object" &&
- "props" in codeChild
- ) {
- const el = codeChild as {
- props: {
- className?: string;
- children?: string;
- };
- };
- const cls = el.props?.className;
- const match = cls?.match(/language-(\w+)/);
- if (match) lang = match[1];
- if (
- typeof el.props?.children === "string"
- ) {
- code = el.props.children;
- }
- }
-
- const highlighted =
- lang && code
- ? highlighter.codeToHtml(code, {
- lang,
- themes: {
- dark: "catppuccin-macchiato",
- light: "catppuccin-latte",
- },
- defaultColor: false,
- })
- : null;
-
- const copyRef = useRef
- {children}
-
- );
- },
-
- h1({
- children,
- }: ComponentPropsWithoutRef<"h1">): ReactElement {
- return (
- - {children} -
- ); - }, - - ul({ - children, - }: ComponentPropsWithoutRef<"ul">): ReactElement { - return ( -- {children} -- ); - }, - - table({ - children, - }: ComponentPropsWithoutRef<"table">): ReactElement { - return ( -