]> Lady’s Gitweb - GitWikiWeb/blobdiff - build.js
Don’t add .sig links to the internal links list
[GitWikiWeb] / build.js
index 3d3a862c3f09af3e5ddc72dc9a89934a4c5263c2..3b40c3a347fa98ab45f0dd59a67fb317e03b5ca6 100644 (file)
--- a/build.js
+++ b/build.js
@@ -147,8 +147,8 @@ const logErrorsAndCollectResults = (results) =>
   });
 
 const getReferenceFromPath = (path) =>
-  /Sources\/([A-Z][0-9A-Za-z]*\/[A-Z][0-9A-Za-z]*)\.djot$/u.exec(path)
-    ?.[1]?.replace?.("/", ":");
+  /Sources\/([A-Z][0-9A-Za-z]*(?:\/[A-Z][0-9A-Za-z]*)+)\.djot$/u
+    .exec(path)?.[1]?.replace?.("/", ":"); // only replaces first slash
 
 const listOfInternalLinks = (references, wrapper = ($) => $) => ({
   tag: "bullet_list",
@@ -331,7 +331,7 @@ class GitWikiWebPage {
             e.attributes ??= {};
             const { attributes, reference, destination } = e;
             if (
-              /^(?:[A-Z][0-9A-Za-z]*|[@#])?:(?:[A-Z][0-9A-Za-z]*)?$/u
+              /^(?:[A-Z][0-9A-Za-z]*|[@#])?:(?:[A-Z][0-9A-Za-z]*(?:\/[A-Z][0-9A-Za-z]*)*)?$/u
                 .test(reference ?? "")
             ) {
               const [namespacePrefix, pageName] = splitReference(
@@ -345,11 +345,20 @@ class GitWikiWebPage {
               const resolvedReference = pageName == ""
                 ? `Namespace:${expandedNamespace}`
                 : `${expandedNamespace}:${pageName}`;
-              this.#internalLinks.add(resolvedReference);
               e.reference = resolvedReference;
               attributes["data-realm"] = "internal";
               attributes["data-pagename"] = pageName;
               attributes["data-namespace"] = expandedNamespace;
+              if (
+                resolvedReference.startsWith("Editor:") &&
+                (attributes.class ?? "").split(/\s/gu).includes("sig")
+              ) {
+                // This is a special internal link; do not record it.
+                /* do nothing */
+              } else {
+                // This is a non‐special internal link; record it.
+                internalLinks.add(resolvedReference);
+              }
             } else {
               attributes["data-realm"] = "external";
               const remote = destination ??
@@ -594,6 +603,7 @@ class GitWikiWebPage {
                 `GitWikiWeb: git cat-file returned nonzero exit code: ${catstatus.code}.`,
               );
             } else {
+              const reference = `${namespace}:${pageName}`;
               const page = new GitWikiWebPage(
                 namespace,
                 pageName,
@@ -604,7 +614,6 @@ class GitWikiWebPage {
                 source,
                 config,
               );
-              const reference = `${namespace}:${pageName}`;
               pages.set(reference, page);
               requiredButMissingPages.delete(reference);
             }
This page took 0.022804 seconds and 4 git commands to generate.