]> Lady’s Gitweb - GitWikiWeb/blobdiff - build.js
Move symbol definition into external config file
[GitWikiWeb] / build.js
index df9c016600b3fdf9539de47d162d7ff944fc9dc9..e8b700344c66acd85b81731b1f9324d68bdd3954 100644 (file)
--- a/build.js
+++ b/build.js
 import {
   emptyDir,
   ensureDir,
-} from "https://deno.land/std@0.195.0/fs/mod.ts";
+} from "https://deno.land/std@0.196.0/fs/mod.ts";
+import {
+  JSON_SCHEMA,
+  parse as parseYaml,
+} from "https://deno.land/std@0.196.0/yaml/mod.ts";
 import djot from "npm:@djot/djot@0.2.3";
 import { Parser } from "npm:htmlparser2@9.0.0";
 import { DomHandler, Element, Text } from "npm:domhandler@5.0.3";
@@ -217,7 +221,7 @@ class GitWikiWebPage {
   #internalLinks = new Set();
   #externalLinks = new Map();
 
-  constructor(namespace, name, ast, source) {
+  constructor(namespace, name, ast, source, config) {
     const internalLinks = this.#internalLinks;
     const externalLinks = this.#externalLinks;
     const sections = Object.create(null);
@@ -480,23 +484,8 @@ class GitWikiWebPage {
                 String.fromCodePoint(parseInt(codepoint, 16))
               }`;
             } else {
-              return {
-                "--8": str`${"—\u2060:\u202F"}`, // reverse puppyprick
-                "8--": str`${"\u202F:\u2060—"}`, // forward puppyprick
-                sp: rawInline` `, // space
-                nbsp: str`${"\xA0"}`, // no‐break space
-                cgj: str`${"\u034F"}`, // combining grapheme joiner
-                ensp: str`${"\u2002"}`, // enspace
-                emsp: str`${"\u2003"}`, // emspace
-                figsp: str`${"\u2007"}`, // figure space
-                zwsp: str`${"\u200B"}`, // zero‐width space
-                zwnj: str`${"\u200C"}`, // zero‐width nonjoiner
-                zwj: str`${"\u200D"}`, // zero‐width joiner
-                nnbsp: str`${"\u202F"}`, // narrow no‐break space
-                mathsp: str`${"\u205F"}`, // math space
-                wj: str`${"\u2060"}`, // word joiner
-                fwsp: str`${"\u3000"}`, // fullwidth space
-              }[alias] ?? e;
+              const resolved = config.symbols?.[alias];
+              return resolved != null ? str`${resolved}` : e;
             }
           },
         },
@@ -524,6 +513,9 @@ class GitWikiWebPage {
 }
 
 {
+  const config = await getRemoteContent("config.yaml").then((yaml) =>
+    parseYaml(yaml, { schema: JSON_SCHEMA })
+  );
   const ls = new Deno.Command("git", {
     args: ["ls-tree", "-rz", "live"],
     stdout: "piped",
@@ -597,6 +589,7 @@ class GitWikiWebPage {
                     console.warn(`Djot(${reference}): ${$.render()}`),
                 }),
                 source,
+                config,
               );
               const reference = `${namespace}:${pageName}`;
               pages.set(reference, page);
@@ -618,6 +611,7 @@ class GitWikiWebPage {
             console.warn(`Djot(${reference}): ${$.render()}`),
         }),
         source,
+        config,
       );
       pages.set(reference, page);
     }
This page took 0.077764 seconds and 4 git commands to generate.