diff --git a/src/components/CodeBlock.tsx b/src/components/CodeBlock.tsx new file mode 100644 index 0000000..972ed97 --- /dev/null +++ b/src/components/CodeBlock.tsx @@ -0,0 +1,21 @@ +import { useEffect, useRef } from "react" +import hljs from "highlight.js" +import "highlight.js/styles/atom-one-dark.css" // or any theme you prefer + +export default function CodeBlock({ children, className }) { + const codeRef = useRef(null) + + useEffect(() => { + if (codeRef.current) { + hljs.highlightElement(codeRef.current) + } + }, [children, className]) + + return ( +
+			
+				{children}
+			
+		
+ ) +} diff --git a/src/templates/Entry.tsx b/src/templates/Entry.tsx index 0943dab..8e32e19 100644 --- a/src/templates/Entry.tsx +++ b/src/templates/Entry.tsx @@ -1,6 +1,88 @@ import { useParams } from "react-router" import Page from "./Page" +import { useQuery } from "@tanstack/react-query" +import api from "@/api/eolas-api" +import ReactMarkdown from "react-markdown" +import remarkGfm from "remark-gfm" +import CodeBlock from "@/components/CodeBlock" +import remarkMath from "remark-math" +import rehypeKatex from "rehype-katex" +import "katex/dist/katex.min.css" + export default function Entry() { const { entry } = useParams() - return {entry?.replace(/_/g, " ")}} /> + + const { data, isLoading } = useQuery({ + queryKey: [`entry_${entry}`], + queryFn: () => api.get(`/entries/${entry}`).then((res) => res.data), + }) + + return ( + {entry?.replace(/_/g, " ")}} + pageBody={} + /> + ) +} + +const EntryBody = ({ body }) => { + console.log(body) + return ( +
+ null, + h2: ({ children }) => ( +

{children}

+ ), + h3: ({ children }) => ( +

{children}

+ ), + h4: ({ children }) => ( +

{children}

+ ), + p: ({ children }) =>

{children}

, + ul: ({ children }) =>
    {children}
, + ol: ({ children }) => ( +
    {children}
+ ), + a: ({ href, children }) => ( + + {children} + + ), + table: ({ children }) => {children}
, + tr: ({ children }) => {children}, + th: ({ children }) => ( + + {children} + + ), + td: ({ children }) => ( + + {children} + + ), + blockquote: ({ children }) => ( +
+ {children} +
+ ), + pre: ({ children }) => { + const child = children.props + return {child.children} + }, + code: ({ children }) => ( + + {children} + + ), + }} + > + {body} +
+
+ ) }