Skip to content

Commit

Permalink
feat: add latex math support
Browse files Browse the repository at this point in the history
  • Loading branch information
arian81 committed Jun 9, 2024
1 parent 7e6684a commit 12504dc
Show file tree
Hide file tree
Showing 3 changed files with 160 additions and 2 deletions.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@
"react-dom": "18.2.0",
"react-markdown": "^9.0.1",
"rehype-highlight": "^7.0.0",
"rehype-katex": "^7.0.0",
"remark-gfm": "^4.0.0",
"remark-math": "^6.0.0",
"sanity": "^3.25.0",
"sanity-plugin-markdown": "^4.1.2",
"styled-components": "^6.1.8",
Expand Down
154 changes: 154 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions src/pages/blog/[slug].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import ImageModal from "~/components/ImageModal";
import Markdown from "react-markdown";
import remarkGfm from "remark-gfm";
import rehypeHighlight from "rehype-highlight";
import remarkMath from "remark-math";
import rehypeKatex from "rehype-katex";

const markdown =
"``` js\nvar foo = function (bar) {\n return bar++;\n};\n\nconsole.log(foo(5));\n ```\n Just a link: www.nasa.gov.";
Expand All @@ -37,8 +39,8 @@ const BlogPost: NextPageWithLayout<
< */}
<div className="prose w-screen p-5">
<Markdown
remarkPlugins={[remarkGfm]}
rehypePlugins={[rehypeHighlight]}
remarkPlugins={[remarkGfm, remarkMath]}
rehypePlugins={[rehypeHighlight, rehypeKatex]}
>
{post.body}
</Markdown>
Expand Down

0 comments on commit 12504dc

Please sign in to comment.