diff --git a/_config.ts b/_config.ts index bc4922b..f1848d7 100644 --- a/_config.ts +++ b/_config.ts @@ -6,15 +6,12 @@ import feed from "lume/plugins/feed.ts"; import code_highlight from "lume/plugins/code_highlight.ts"; import toc from "lume-markdown-plugins/toc.ts"; import footnotes from "lume-markdown-plugins/footnotes.ts"; +import kroki from "https://code.fosterhangdaan.com/foster/lume-plugin-kroki/raw/tag/v1.0.0/mod.ts"; import lang_typescript from "npm:highlight.js/lib/languages/typescript"; import lang_javascript from "npm:highlight.js/lib/languages/javascript"; import lang_bash from "npm:highlight.js/lib/languages/bash"; -import { deflateSync } from "node:zlib"; - -const textEncoder = new TextEncoder(); - const site = lume({ src: "./src", location: new URL("https://www.fosterhangdaan.com/"), @@ -78,6 +75,9 @@ site.use(toc({ }, })); site.use(footnotes()); +site.use(kroki({ + server: "https://kroki.fosterhangdaan.com", +})); site.process([".html"], (pages) => { pages.forEach((page) => { @@ -98,28 +98,6 @@ site.process([".html"], (pages) => { codeCommentElement.classList.add("docstring"); } } - - /** - * Convert Plantuml code to images using Kroki. - */ - const diagrams = page.document.getElementsByClassName( - "language-plantuml", - ); - if (diagrams.length > 0) { - for (const diagram of diagrams) { - if (diagram.textContent && diagram.parentElement) { - const encoded = textEncoder.encode(diagram.textContent); - const compressed = deflateSync(encoded); - const result = compressed.toString("base64url"); - const img = page.document.createElement("img"); - const url = new URL( - `https://kroki.fosterhangdaan.com/plantuml/svg/${result}`, - ); - img.setAttribute("src", url.toString()); - diagram.parentElement.replaceWith(img); - } - } - } } }); }); diff --git a/deno.json b/deno.json index 265b889..397dffb 100644 --- a/deno.json +++ b/deno.json @@ -10,7 +10,7 @@ "tasks": { "build": "deno run --allow-write='.' --allow-read='.' --allow-net='deno.land,cdn.deno.land,esm.sh,0.0.0.0:3000,jsr.io,lumeland.github.io' --allow-sys=networkInterfaces --allow-env='LUME_ENV,LUME_LIVE_RELOAD,LUME_LOGS,LUME_NOCACHE,LUME_DRAFTS,NODE_ENV,SASS_PATH' lume.ts", "check": "deno fmt --check && deno lint && deno check .", - "serve": "deno run --allow-write='.' --allow-read='.' --allow-net='deno.land,cdn.deno.land,esm.sh,0.0.0.0:3000,jsr.io,lumeland.github.io' --allow-sys=networkInterfaces --allow-env='LUME_ENV,LUME_LIVE_RELOAD,LUME_LOGS,LUME_NOCACHE,LUME_DRAFTS,NODE_ENV,SASS_PATH' lume.ts -s", + "serve": "deno run --allow-write='.' --allow-read='.' --allow-net='deno.land,cdn.deno.land,esm.sh,0.0.0.0:3000,jsr.io,lumeland.github.io,code.fosterhangdaan.com' --allow-sys=networkInterfaces --allow-env='LUME_ENV,LUME_LIVE_RELOAD,LUME_LOGS,LUME_NOCACHE,LUME_DRAFTS,NODE_ENV,SASS_PATH' lume.ts -s", "deploy": "rsync -avh --progress --delete ./_site/ podman:/srv/www/fosterhangdaan.com/" }, "imports": { diff --git a/deno.lock b/deno.lock index e40a055..3c6531b 100644 Binary files a/deno.lock and b/deno.lock differ