From 89efa55861ec0a181bbe340596c11e6b9e484543 Mon Sep 17 00:00:00 2001 From: Foster Hangdaan Date: Fri, 8 Nov 2024 17:02:47 -0500 Subject: [PATCH] Install Kroki plugin --- _config.ts | 30 ++++-------------------------- deno.json | 2 +- deno.lock | Bin 164909 -> 166554 bytes 3 files changed, 5 insertions(+), 27 deletions(-) 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 e40a055c5d5c1ec6fcc54fefa32b501812d3f1a9..3c6531be94b7d6ea1dbb736fffd39cd444fbedc0 100644 GIT binary patch delta 1186 zcmb`Fy^mB?7{)Wm4$IwDm&_0_vMYCJEMV^W{+JM$YB5?E4Z&Dgyyt5ec4uapdlwQz zvJxyH6hKal(MCdHXJT>_Ei8j^bU88DlyQ6uKNTelv5eCy%-e?M%;qq`RBPa7X( z@$Tw;{JQx{Tv^yt|GaRmv1eTQ=@{1I?Phy^_@rnwUyJ{&X7z_JkDBq5UiOme^y1xp z?bvFyW52yOF6sGrb#XEN)%tbWm(_4QctpjX!L3p!UTPkSH}=ofKeVs!ia%y^`~s{G z&7>+GpMBJ2q>G>a`22Q#{6LXqJNje3x_nYF>vaIDr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