Compare commits

...

5 commits

7 changed files with 100 additions and 55 deletions

View file

@ -6,7 +6,7 @@ A [[https://lume.land/][Lume]] plugin which utilizes [[https://kroki.io/][Kroki]
* Documentation
For documentation, refer to [[https://code.fosterhangdaan.com/foster/lume-plugin-kroki/wiki][the wiki]].
For documentation, refer to [[https://code.hangdaan.com/foster/lume-plugin-kroki/wiki][the wiki]].
* License
@ -16,4 +16,4 @@ Unless required by applicable law or agreed to in writing, software distributed
* Copyright
Copyright \copy 2024 [[https://www.fosterhangdaan.com][Foster Hangdaan]]
Copyright \copy 2024 [[https://www.foster.hangdaan.com][Foster Hangdaan]]

View file

@ -1,8 +1,14 @@
{
"version": "1.0.0",
"version": "1.0.1",
"exports": "./mod.ts",
"tasks": {
"check": "deno fmt --check && deno lint && deno check .",
"test": "deno test --allow-read=. --allow-write=./tests/site/_site,./tests/__snapshots__ --deny-env"
},
"imports": {
"@std/assert": "jsr:@std/assert@1.0.7",
"@std/path": "jsr:@std/path@1.0.8",
"@std/testing": "jsr:@std/testing@1.0.4",
"lume/": "https://deno.land/x/lume@v2.4.1/"
}
}

72
deno.lock generated
View file

@ -327,6 +327,71 @@
"https://deno.land/x/lume@v2.4.0/plugins/url.ts": "3718185697778f3b4dd17924d9d282d0a5a74030301e7fcae8a7f1b21f0ef9a9",
"https://deno.land/x/lume@v2.4.0/plugins/vento.ts": "638ac1abe3086b43bc704ace0c99bb2c201c1e55418b84a73ef79d875344a44c",
"https://deno.land/x/lume@v2.4.0/plugins/yaml.ts": "8cb20b4bf3a265be0d975235b537c9807db2f34d357fc27546c05d628d3fda9f",
"https://deno.land/x/lume@v2.4.1/core/component_loader.ts": "da80bf80a168d0b91b59eb3449fbf62627d8bf67879df34e71970616d47ce2ec",
"https://deno.land/x/lume@v2.4.1/core/data_loader.ts": "8698a9e9b1aac27147dc835ba89a0e30828c81338eceae86630607d78f146215",
"https://deno.land/x/lume@v2.4.1/core/events.ts": "e4fd1786eb7dd4a041d7d922779b9edf1ee89e51fd17ba5e756f380879ccb557",
"https://deno.land/x/lume@v2.4.1/core/file.ts": "27c04304793dec9972a24575ade217ace1eb204dd342d03930fd51fa5b8c2fbb",
"https://deno.land/x/lume@v2.4.1/core/formats.ts": "24d9f5ccf384b2474f457cc0d3855e6ad411ded0d6acf4afe36547ba93fc706f",
"https://deno.land/x/lume@v2.4.1/core/fs.ts": "6e22f7c88ef594d527a9efff6e00ec9491f695e39694d7ac355c4de90dbf0952",
"https://deno.land/x/lume@v2.4.1/core/loaders/binary.ts": "bb1e1cf3faac49f6007dc6814168dc0f633da17356db18e68862e4b2a87a3f33",
"https://deno.land/x/lume@v2.4.1/core/loaders/json.ts": "632e840340edf7d79091fb37474a1cbf86dd2d218090fb6f6c0420f5f5e9c2ce",
"https://deno.land/x/lume@v2.4.1/core/loaders/mod.ts": "f33af1a2fa0913cf393cd9ef6bf5aea2d03d1058e8966ad7f1483efbcc7df118",
"https://deno.land/x/lume@v2.4.1/core/loaders/module.ts": "abcb210fa6724b83407407cd0f7ef90462b35a2017bc135a3d124dd7f38843f6",
"https://deno.land/x/lume@v2.4.1/core/loaders/text.ts": "42860fc3482651fa6cfba18a734bb548d6e6e1163bf1015c2abc447ab150acbd",
"https://deno.land/x/lume@v2.4.1/core/loaders/toml.ts": "72ddfef2deea62815c28e27faa2c5356e09b3109e9547e47a6defea3d3332452",
"https://deno.land/x/lume@v2.4.1/core/loaders/yaml.ts": "241dc41fbe51b92e38dc748eda614c35d80fb8c63a6d40253453c6bb78c9c47e",
"https://deno.land/x/lume@v2.4.1/core/processors.ts": "ce9b97307740723afd86d1773e946981a96769189ba6acd649b412e48552045d",
"https://deno.land/x/lume@v2.4.1/core/renderer.ts": "b1879895f7544326e61e95a6413689975e79eabae0c48ca5912f06d2b4afde43",
"https://deno.land/x/lume@v2.4.1/core/scopes.ts": "dbdf93d7a9cead84833779e974f190b1379356ec7c0ccd34aa92f917c2cdd2f9",
"https://deno.land/x/lume@v2.4.1/core/scripts.ts": "286969b120d2290ba57a7fdd9b37e587aacf4e4162d92f51f1f1e9e18c864f30",
"https://deno.land/x/lume@v2.4.1/core/searcher.ts": "9093c2c64d1190b55a886b2905a224e0cbf86532bea4883e065e391851a8f14c",
"https://deno.land/x/lume@v2.4.1/core/server.ts": "aa8f7bf3dd89bfc3ff648c191950df0f4d5115efd73fdd07f9ceecaff7c89bf1",
"https://deno.land/x/lume@v2.4.1/core/site.ts": "36ebeba154578326b904490791dd05625690a6d0b0e079e6a42dd52179993ae1",
"https://deno.land/x/lume@v2.4.1/core/source.ts": "1a7541e4df6fafa8c2c6417088cb31980dbda0eea42b93a1263f119f79349de2",
"https://deno.land/x/lume@v2.4.1/core/utils/cli_options.ts": "0e48094ef8b89502c53fa597e01238c2ca972f65d2b9b219cca42a3988cba3c6",
"https://deno.land/x/lume@v2.4.1/core/utils/concurrent.ts": "cb0775b3d95f3faa356aa3a3e489dccef8807ed93cc4f84fcf5bc81e87c29504",
"https://deno.land/x/lume@v2.4.1/core/utils/date.ts": "4972e6e43d9756a3858494004e1b45df3b947033abe68db02acfc0bbb7847ce1",
"https://deno.land/x/lume@v2.4.1/core/utils/digest.ts": "445b387983391af73269686292a65bb677119a25a327776885ff1242a9397ad8",
"https://deno.land/x/lume@v2.4.1/core/utils/dom.ts": "d406fb5c48ceb012286d0aff66ef635261eda666de2ce07538c0cf9366b8fecd",
"https://deno.land/x/lume@v2.4.1/core/utils/env.ts": "d2440f14ad27e65b0a42b35a52f59ccce0430dd52950bd5df103bb1c9ba1a4a7",
"https://deno.land/x/lume@v2.4.1/core/utils/generator.ts": "1e664e9fd4c469e38a0acf5c94fd49dac4f38cb6334563ea4b7fc498b5958877",
"https://deno.land/x/lume@v2.4.1/core/utils/log.ts": "9b229e345d85ce8bd2d108bff99c8c57fcbded62e65776af294f94f349b48641",
"https://deno.land/x/lume@v2.4.1/core/utils/merge_data.ts": "a574d97eeaa1513d30440488f52e988f0fe2085397611852673cea10076f01ff",
"https://deno.land/x/lume@v2.4.1/core/utils/object.ts": "e00ee6e91264064772c87e69e128a09ba0e30c2c41be4a5302881f59f456fc31",
"https://deno.land/x/lume@v2.4.1/core/utils/page_content.ts": "e7d4323a7b66d1ae26c1263dd5a13a0c5e9f73583c9cf83454ad61f157d8351d",
"https://deno.land/x/lume@v2.4.1/core/utils/page_date.ts": "2a3d9c203df298ca61f568fdf509945f127f990769623c3edfd753d39807b757",
"https://deno.land/x/lume@v2.4.1/core/utils/page_url.ts": "8d672d6e292a50952727dda75edd70d7ec98d793de569b24e1f90a35e7836b16",
"https://deno.land/x/lume@v2.4.1/core/utils/path.ts": "109b9a6c450929db4f7b133859f5eebbe92999d3cc523a19988a058abec582b5",
"https://deno.land/x/lume@v2.4.1/core/utils/read.ts": "e096b1f37f8f0a6820e6ee00af1832d133598d55c961b226d057a5467207c5cd",
"https://deno.land/x/lume@v2.4.1/core/watcher.ts": "6c6c4b5feb540958bfd3ca78f420f4278d39eb317e9476aeec85d0ca69368873",
"https://deno.land/x/lume@v2.4.1/core/writer.ts": "7c56cdae2fcbaebe3c4d66d6c75bc056906d82517d880ba8e02acbb464e6c6b6",
"https://deno.land/x/lume@v2.4.1/deps/cli.ts": "76e87147c435c9b73932cd340bb0bc192e8ceef757693a10359d8c312f0c9636",
"https://deno.land/x/lume@v2.4.1/deps/colors.ts": "8642f31364e8d1b7c3bba56cfee21f8abdd545b5e1c8350cfcc104531eca164c",
"https://deno.land/x/lume@v2.4.1/deps/crypto.ts": "020df39e6ba16ec8f3936b0ceff03a3d64bde8900a976ba3a519b5cc09d337d2",
"https://deno.land/x/lume@v2.4.1/deps/dom.ts": "5670c225863738487fb03d19524dfcdd6d08c8851ffc9435d7142806cea6a458",
"https://deno.land/x/lume@v2.4.1/deps/front_matter.ts": "279c53db46ac7f557f217ffb7fbd0c307ad6cbd8ff64d91cd8b023a3b50b2c92",
"https://deno.land/x/lume@v2.4.1/deps/fs.ts": "bd02b4f76a5579908f28d8af86c3adce1dc5c6024a229e4f3b013a1540856546",
"https://deno.land/x/lume@v2.4.1/deps/hex.ts": "345dabf92ede0e4b1aed5b6d831099bcf62ec0f75d45519e42194ee527f7c8b9",
"https://deno.land/x/lume@v2.4.1/deps/http.ts": "acc7512e6835c9f127b6e90b46b1aa8ccab433ccc0d1e38466eacf66c0eaf28b",
"https://deno.land/x/lume@v2.4.1/deps/jsonc.ts": "e359eb0ef9f5f15518e6afe9bafb5b48bd5798dc000c8e210953c29cb319e607",
"https://deno.land/x/lume@v2.4.1/deps/log.ts": "0906e1383988ebbfb6343a3692077e5d75ec1e649d93a0c0009c0c430b67eea3",
"https://deno.land/x/lume@v2.4.1/deps/markdown_it.ts": "f68bb28890f77347ac7bc980026ea52e3cf0940278a3930428f5900be9e6491f",
"https://deno.land/x/lume@v2.4.1/deps/path.ts": "2cb9b457032c687de61df71a5855a97d7de18386bfe3048c03377c733e96b3ab",
"https://deno.land/x/lume@v2.4.1/deps/temporal.ts": "1958b134c4186b0ab39316fa33ba19d1a4203e2ea445080429d60d296b91a552",
"https://deno.land/x/lume@v2.4.1/deps/toml.ts": "8d103f6379d09750299ea91d71293a851f69b4cf011bdb7a1323409206eca59f",
"https://deno.land/x/lume@v2.4.1/deps/vento.ts": "50bb794a4aa7a65c0394d585277bfe85f2c44fd19a0d848dfa54cba52cf55b62",
"https://deno.land/x/lume@v2.4.1/deps/yaml.ts": "cbcf4d295ed88066e12a718750f09cebbf30fefa32e186844b597bce74b35557",
"https://deno.land/x/lume@v2.4.1/middlewares/not_found.ts": "4507842d422267062c34662dceab17affcaad01858a5890fda163a8ddeb31487",
"https://deno.land/x/lume@v2.4.1/mod.ts": "f93dcbc0ccb7a9e6cab93d0e8f1f0643b112f3084bedc603379dc1b47d7d380d",
"https://deno.land/x/lume@v2.4.1/plugins/json.ts": "67e5e2e00f8e8640f33c1f97a2bf82a7c97a67a838804637b87b16b72f9042e1",
"https://deno.land/x/lume@v2.4.1/plugins/markdown.ts": "c7027605edee274762edb20f7040ccba6415c5fe656cc6e25ce91c448f467fd8",
"https://deno.land/x/lume@v2.4.1/plugins/modules.ts": "e64197315d930e462aca24e444d0cfcefb37bfea168b2306122b892a1e1c5b8e",
"https://deno.land/x/lume@v2.4.1/plugins/paginate.ts": "7dfee977a205dfe0af33a3e406f73017badd2d4593cf27e5bd897da7ab12ba8a",
"https://deno.land/x/lume@v2.4.1/plugins/search.ts": "ff570560c6ca95598a1cbfb3a77611477ee7dbb53300bcc3ba14d18c9e5eba79",
"https://deno.land/x/lume@v2.4.1/plugins/toml.ts": "72c75546056e503a59752e33dc25542f2aa21d743bd47f498d722b97958212f5",
"https://deno.land/x/lume@v2.4.1/plugins/url.ts": "3718185697778f3b4dd17924d9d282d0a5a74030301e7fcae8a7f1b21f0ef9a9",
"https://deno.land/x/lume@v2.4.1/plugins/vento.ts": "638ac1abe3086b43bc704ace0c99bb2c201c1e55418b84a73ef79d875344a44c",
"https://deno.land/x/lume@v2.4.1/plugins/yaml.ts": "8cb20b4bf3a265be0d975235b537c9807db2f34d357fc27546c05d628d3fda9f",
"https://deno.land/x/vento@v1.12.11/deps.ts": "47ad104c87a32292e978f0fba4f69954f7feff3b403833858e1cc51c5313e9db",
"https://deno.land/x/vento@v1.12.11/mod.ts": "296c9cc4253c1b88a94fc630a05d9a12947a908966f2db43968141f1c282a7d6",
"https://deno.land/x/vento@v1.12.11/plugins/echo.ts": "59adb9137e736029cf18e3d95e010803c8728046d0d040702c16c4930c7b6160",
@ -347,5 +412,12 @@
"https://deno.land/x/vento@v1.12.11/src/loader.ts": "c05add67f582e937ee611852075ce2cc038b5e80e3e609eef96fa5ed74a5086c",
"https://deno.land/x/vento@v1.12.11/src/tokenizer.ts": "127ddad02054f63b8b646e4dfbf555e1e34e9b8dcbd58d86b3729a4de95abd27",
"https://deno.land/x/vento@v1.12.11/src/transformer.ts": "587a0b107a2bd1437a3093c4c44c07e4fdf3abfaaf8e845767b69bd34a039154"
},
"workspace": {
"dependencies": [
"jsr:@std/assert@1.0.7",
"jsr:@std/path@1.0.8",
"jsr:@std/testing@1.0.4"
]
}
}

26
deps.ts
View file

@ -14,30 +14,4 @@
* limitations under the License.
*/
// Lume
export {
default as LumeSite,
type SiteOptions as LumeSiteOptions,
} from "https://deno.land/x/lume@v2.4.0/core/site.ts";
export {
default as lume,
type PluginOptions as LumePluginOptions,
} from "https://deno.land/x/lume@v2.4.0/mod.ts";
export {
type DeepPartial as LumeDeepPartial,
} from "https://deno.land/x/lume@v2.4.0/core/utils/object.ts";
export {
type Writer as LumeWriter,
} from "https://deno.land/x/lume@v2.4.0/core/writer.ts";
// STD Assert
export { assertExists, assertInstanceOf } from "jsr:@std/assert@1.0.7";
// STD Testing
export { assertSnapshot } from "jsr:@std/testing@1.0.4/snapshot";
// STD Path
export { fromFileUrl, join } from "jsr:@std/path@1.0.8";
// Valibot
export * as valibot from "jsr:@valibot/valibot@0.42.1";

7
mod.ts
View file

@ -14,8 +14,9 @@
* limitations under the License.
*/
import { valibot as v } from "./deps.ts";
import Site from "lume/core/site.ts";
import diagrams from "./resources/diagrams.json" with { type: "json" };
import { LumeSite, valibot as v } from "./deps.ts";
import { deflateSync } from "node:zlib";
const textEncoder = new TextEncoder();
@ -66,10 +67,10 @@ const OptionsSchema = v.optional(
export type Options = v.InferInput<typeof OptionsSchema>;
export default function (options?: Options): (site: LumeSite) => void {
export default function (options?: Options): (site: Site) => void {
const opts = v.parse(OptionsSchema, options);
return (site: LumeSite) => {
return (site: Site) => {
site.process([".html"], (pages) => {
pages.forEach((page) => {
diagrams.forEach((diagram) => {

View file

@ -15,13 +15,10 @@
*/
import mod from "../mod.ts";
import { valibot as v } from "../deps.ts";
import { assertExists, assertInstanceOf } from "@std/assert";
import { assertSnapshot } from "@std/testing/snapshot";
import { getSite } from "./utils.ts";
import {
assertExists,
assertInstanceOf,
assertSnapshot,
valibot,
} from "../deps.ts";
Deno.test("Error thrown on invalid options", async (t) => {
await t.step("Invalid server", () => {
@ -32,7 +29,7 @@ Deno.test("Error thrown on invalid options", async (t) => {
error = err;
}
assertExists(error);
assertInstanceOf(error, valibot.ValiError);
assertInstanceOf(error, v.ValiError);
});
await t.step("Invalid enabledDiagrams", () => {
@ -43,7 +40,7 @@ Deno.test("Error thrown on invalid options", async (t) => {
error = err;
}
assertExists(error);
assertInstanceOf(error, valibot.ValiError);
assertInstanceOf(error, v.ValiError);
});
await t.step("Invalid format", () => {
@ -55,7 +52,7 @@ Deno.test("Error thrown on invalid options", async (t) => {
error = err;
}
assertExists(error);
assertInstanceOf(error, valibot.ValiError);
assertInstanceOf(error, v.ValiError);
});
});

View file

@ -14,20 +14,15 @@
* limitations under the License.
*/
import {
fromFileUrl,
join,
lume,
type LumeDeepPartial,
type LumePluginOptions,
LumeSite,
type LumeSiteOptions,
type LumeWriter,
} from "../deps.ts";
import Site, { SiteOptions } from "lume/core/site.ts";
import lume, { PluginOptions } from "lume/mod.ts";
import { DeepPartial } from "lume/core/utils/object.ts";
import { Writer } from "lume/core/writer.ts";
import { fromFileUrl, join } from "@std/path";
const cwd = fromFileUrl(import.meta.resolve("./"));
class TestWriter implements LumeWriter {
class TestWriter implements Writer {
savePages() {
return Promise.resolve([]);
}
@ -46,9 +41,9 @@ class TestWriter implements LumeWriter {
}
export function getSite(
siteOptions: LumeDeepPartial<LumeSiteOptions> = {},
pluginOptions: LumePluginOptions = {},
): LumeSite {
siteOptions: DeepPartial<SiteOptions> = {},
pluginOptions: PluginOptions = {},
): Site {
siteOptions.cwd = join(cwd, "site");
const site = lume(