Skip to content

Commit

Permalink
feat: tikz ssr
Browse files Browse the repository at this point in the history
  • Loading branch information
mensah-j committed Nov 17, 2024
1 parent ee5747c commit 0d7b8b2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
11 changes: 2 additions & 9 deletions src/app/_components/TikzDiagram/TikzDiagram.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,16 @@
import tex2svg from "@lib/tikzjax/dist";
import "@lib/tikzjax/css/fonts.css";
import { compileTikz } from "./compile";

interface TikzDiagramProps {
source: string;
}

export async function TikzDiagram(props: TikzDiagramProps) {
async function compileTikz() {
"use server";
return await tex2svg(props.source, {
showConsole: true,
});
}

return (
<main className="flex flex-col items-center grow p-2">
<div
style={{ zoom: 1.5 }}
dangerouslySetInnerHTML={{ __html: await compileTikz() }}
dangerouslySetInnerHTML={{ __html: await compileTikz(props.source) }}
></div>
</main>
);
Expand Down
9 changes: 9 additions & 0 deletions src/app/_components/TikzDiagram/compile.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
"use server";

import tex2svg from "@lib/tikzjax/dist";

export async function compileTikz(source: string) {
return await tex2svg(source, {
showConsole: true,
});
}

0 comments on commit 0d7b8b2

Please sign in to comment.