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 --- a/deno.lock +++ b/deno.lock @@ -5,8 +5,10 @@ "jsr:@davidbonnet/astring@1.8.6": "jsr:@davidbonnet/astring@1.8.6", "jsr:@libs/typing@2": "jsr:@libs/typing@2.9.0", "jsr:@libs/typing@3": "jsr:@libs/typing@3.1.0", + "jsr:@std/assert@1.0.7": "jsr:@std/assert@1.0.7", "jsr:@std/assert@^0.224.0": "jsr:@std/assert@0.224.0", "jsr:@std/assert@^0.226.0": "jsr:@std/assert@0.226.0", + "jsr:@std/assert@^1.0.7": "jsr:@std/assert@1.0.7", "jsr:@std/cli@0.224.7": "jsr:@std/cli@0.224.7", "jsr:@std/cli@1.0.5": "jsr:@std/cli@1.0.5", "jsr:@std/cli@1.0.6": "jsr:@std/cli@1.0.6", @@ -53,6 +55,7 @@ "jsr:@std/fs@^1.0.0-rc.5": "jsr:@std/fs@1.0.0-rc.6", "jsr:@std/fs@^1.0.3": "jsr:@std/fs@1.0.3", "jsr:@std/fs@^1.0.4": "jsr:@std/fs@1.0.5", + "jsr:@std/fs@^1.0.5": "jsr:@std/fs@1.0.5", "jsr:@std/html@0.224.2": "jsr:@std/html@0.224.2", "jsr:@std/html@1.0.0": "jsr:@std/html@1.0.0", "jsr:@std/html@1.0.3": "jsr:@std/html@1.0.3", @@ -60,6 +63,7 @@ "jsr:@std/http@1.0.5": "jsr:@std/http@1.0.5", "jsr:@std/http@1.0.7": "jsr:@std/http@1.0.7", "jsr:@std/http@1.0.9": "jsr:@std/http@1.0.9", + "jsr:@std/internal@^1.0.5": "jsr:@std/internal@1.0.5", "jsr:@std/io@^0.224.2": "jsr:@std/io@0.224.2", "jsr:@std/io@^0.224.3": "jsr:@std/io@0.224.3", "jsr:@std/io@^0.224.7": "jsr:@std/io@0.224.7", @@ -90,10 +94,12 @@ "jsr:@std/path@^1.0.4": "jsr:@std/path@1.0.4", "jsr:@std/path@^1.0.6": "jsr:@std/path@1.0.6", "jsr:@std/path@^1.0.7": "jsr:@std/path@1.0.8", + "jsr:@std/path@^1.0.8": "jsr:@std/path@1.0.8", "jsr:@std/streams@^0.224.5": "jsr:@std/streams@0.224.5", "jsr:@std/streams@^1.0.4": "jsr:@std/streams@1.0.4", "jsr:@std/streams@^1.0.6": "jsr:@std/streams@1.0.6", "jsr:@std/streams@^1.0.7": "jsr:@std/streams@1.0.8", + "jsr:@std/testing@1.0.4": "jsr:@std/testing@1.0.4", "jsr:@std/toml@0.224.1": "jsr:@std/toml@0.224.1", "jsr:@std/toml@1.0.0": "jsr:@std/toml@1.0.0", "jsr:@std/toml@1.0.1": "jsr:@std/toml@1.0.1", @@ -106,6 +112,7 @@ "jsr:@std/yaml@^0.224.1": "jsr:@std/yaml@0.224.2", "jsr:@std/yaml@^1.0.0-rc.1": "jsr:@std/yaml@1.0.0-rc.1", "jsr:@std/yaml@^1.0.5": "jsr:@std/yaml@1.0.5", + "jsr:@valibot/valibot@0.42.1": "jsr:@valibot/valibot@0.42.1", "npm:@js-temporal/polyfill@0.4.4": "npm:@js-temporal/polyfill@0.4.4", "npm:@types/estree@1.0.5": "npm:@types/estree@1.0.5", "npm:@types/estree@1.0.6": "npm:@types/estree@1.0.6", @@ -156,6 +163,12 @@ "@std/assert@0.226.0": { "integrity": "0dfb5f7c7723c18cec118e080fec76ce15b4c31154b15ad2bd74822603ef75b3" }, + "@std/assert@1.0.7": { + "integrity": "64ce9fac879e0b9f3042a89b3c3f8ccfc9c984391af19e2087513a79d73e28c3", + "dependencies": [ + "jsr:@std/internal@^1.0.5" + ] + }, "@std/cli@0.224.7": { "integrity": "654ca6477518e5e3a0d3fabafb2789e92b8c0febf1a1d24ba4b567aba94b5977" }, @@ -350,6 +363,9 @@ "jsr:@std/streams@^1.0.7" ] }, + "@std/internal@1.0.5": { + "integrity": "54a546004f769c1ac9e025abd15a76b6671ddc9687e2313b67376125650dc7ba" + }, "@std/io@0.224.2": { "integrity": "25ecd4f674527d660ab09e571e15eb541e8eb8a4575f2d20bdbf029374a609b5" }, @@ -482,6 +498,15 @@ "@std/streams@1.0.8": { "integrity": "b41332d93d2cf6a82fe4ac2153b930adf1a859392931e2a19d9fabfb6f154fb3" }, + "@std/testing@1.0.4": { + "integrity": "ca1368d720b183f572d40c469bb9faf09643ddd77b54f8b44d36ae6b94940576", + "dependencies": [ + "jsr:@std/assert@^1.0.7", + "jsr:@std/fs@^1.0.5", + "jsr:@std/internal@^1.0.5", + "jsr:@std/path@^1.0.8" + ] + }, "@std/toml@0.224.1": { "integrity": "c364b9ca3b18207223c4e2a1f652ef2970ff80967f7575ddf89b6b0565a17148", "dependencies": [ @@ -517,6 +542,9 @@ }, "@std/yaml@1.0.5": { "integrity": "71ba3d334305ee2149391931508b2c293a8490f94a337eef3a09cade1a2a2742" + }, + "@valibot/valibot@0.42.1": { + "integrity": "ba0f6f7964aaeec0e4b1f793d575061f325ae6254cbb9d7ff01fb65068a0a23b" } }, "npm": { @@ -955,6 +983,9 @@ } }, "remote": { + "https://code.fosterhangdaan.com/foster/lume-plugin-kroki/raw/tag/v1.0.0/deps.ts": "9eba1f7196ea514a42a817719a490496081a2659b7ea0bf73a7f2a43e1369ba3", + "https://code.fosterhangdaan.com/foster/lume-plugin-kroki/raw/tag/v1.0.0/mod.ts": "3b267950a55b87ac16ed52a4d0ac545d8e290d06b28905a33bfdcf6ec4a8277d", + "https://code.fosterhangdaan.com/foster/lume-plugin-kroki/raw/tag/v1.0.0/resources/diagrams.json": "a1ca8c52b7f5a8d5335d3872ba0c0d2a4b32ef120efd8819557787a4232b649f", "https://deno.land/std@0.170.0/_util/asserts.ts": "d0844e9b62510f89ce1f9878b046f6a57bf88f208a10304aab50efcb48365272", "https://deno.land/std@0.170.0/_util/os.ts": "8a33345f74990e627b9dfe2de9b040004b08ea5146c7c9e8fe9a29070d193934", "https://deno.land/std@0.170.0/encoding/base64.ts": "8605e018e49211efc767686f6f687827d7f5fd5217163e981d8d693105640d7a",