« get me outta code hell

Merge branch 'preview' into image-overlay - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/write
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2023-03-01 16:19:10 -0400
committer(quasar) nebula <qznebula@protonmail.com>2023-03-01 16:19:10 -0400
commit62f64b3aa019747e9c764eda853591b321850ca0 (patch)
tree62e183680ebb4bc5a0015eda957ba367ab11030c /src/write
parent7bf9489f14735f9e44af37f2ade14890a119b403 (diff)
parent1f0924cc94ea10320afe951a2e8fb4906b5e6106 (diff)
Merge branch 'preview' into image-overlay
Diffstat (limited to 'src/write')
-rw-r--r--src/write/bind-utilities.js6
-rw-r--r--src/write/page-template.js106
2 files changed, 88 insertions, 24 deletions
diff --git a/src/write/bind-utilities.js b/src/write/bind-utilities.js
index 127afe2c..427111b4 100644
--- a/src/write/bind-utilities.js
+++ b/src/write/bind-utilities.js
@@ -19,6 +19,7 @@ import {
   generateAdditionalFilesList,
   generateAdditionalFilesShortcut,
   generateChronologyLinks,
+  generateContentHeading,
   generateCoverLink,
   generateInfoGalleryLinks,
   generateTrackListDividedByGroups,
@@ -192,6 +193,11 @@ export function bindUtilities({
     language,
   });
 
+  bound.generateContentHeading = bindOpts(generateContentHeading, {
+    [bindOpts.bindIndex]: 0,
+    html,
+  });
+
   bound.generateStickyHeadingContainer = bindOpts(generateStickyHeadingContainer, {
     [bindOpts.bindIndex]: 0,
     getRevealStringFromArtTags: bound.getRevealStringFromArtTags,
diff --git a/src/write/page-template.js b/src/write/page-template.js
index f47d3f0d..bd52c456 100644
--- a/src/write/page-template.js
+++ b/src/write/page-template.js
@@ -401,6 +401,87 @@ export function generateDocumentHTML(pageInfo, {
     footerHTML,
   ].filter(Boolean).join('\n');
 
+  const processSkippers = skipperList =>
+    skipperList
+      .filter(Boolean)
+      .map(([href, stringSubkey]) =>
+        html.tag('span', {class: 'skipper'},
+          html.tag('a',
+            {href},
+            language.$(`misc.skippers.${stringSubkey}`))));
+
+  // Hilariously jank. Sorry!
+  const hasID = id => mainHTML.includes(`id="${id}"`);
+  const hasContributors = hasID('contributors');
+  const hasReferences = hasID('references');
+  const hasReferencedBy = hasID('referenced-by');
+  const hasSamples = hasID('samples');
+  const hasSampledBy = hasID('sampled-by');
+  const hasFeaturedIn = hasID('featured-in');
+  const hasLyrics = hasID('lyrics');
+  const hasSheetMusicFiles = hasID('sheet-music-files');
+  const hasMidiProjectFiles = hasID('midi-project-files');
+  const hasAdditionalFiles = hasID('additional-files');
+  const hasArtistCommentary = hasID('artist-commentary');
+
+  const skippersHTML =
+    mainHTML &&
+      html.tag('div', {id: 'skippers'}, [
+        html.tag('span', language.$('misc.skippers.skipTo')),
+        html.tag('div', {class: 'skipper-list'},
+          processSkippers([
+            ['#content', 'content'],
+            sidebarLeftHTML &&
+              [
+                '#sidebar-left',
+                sidebarRightHTML
+                  ? 'sidebar.left'
+                  : 'sidebar',
+              ],
+            sidebarRightHTML &&
+              [
+                '#sidebar-right',
+                sidebarLeftHTML
+                  ? 'sidebar.right'
+                  : 'sidebar',
+              ],
+            navHTML &&
+              ['#header', 'header'],
+            footerHTML &&
+              ['#footer', 'footer'],
+          ])),
+
+        html.tag('div',
+          {
+            [html.onlyIfContent]: true,
+            class: 'skipper-list'
+          },
+          processSkippers([
+            hasContributors &&
+              ['#contributors', 'contributors'],
+            hasReferences &&
+              ['#references', 'references'],
+            hasReferencedBy &&
+              ['#referenced-by', 'referencedBy'],
+            hasSamples &&
+              ['#samples', 'samples'],
+            hasSampledBy &&
+              ['#sampled-by', 'sampledBy'],
+            hasFeaturedIn &&
+              ['#featured-in', 'featuredIn'],
+            hasLyrics &&
+              ['#lyrics', 'lyrics'],
+            hasSheetMusicFiles &&
+              ['#sheet-music-files', 'sheetMusicFiles'],
+            hasMidiProjectFiles &&
+              ['#midi-project-files', 'midiProjectFiles'],
+            hasAdditionalFiles &&
+              ['#additional-files', 'additionalFiles'],
+            hasArtistCommentary &&
+              ['#artist-commentary', 'artistCommentary'],
+          ])),
+      ]);
+
   const infoCardHTML = html.tag('div', {id: 'info-card-container'},
     html.tag('div', {id: 'info-card-decor'},
       html.tag('div', {id: 'info-card'}, [
@@ -566,30 +647,7 @@ export function generateDocumentHTML(pageInfo, {
         [
           html.tag('div', {id: 'page-container'}, [
             mainHTML &&
-              html.tag('div', {id: 'skippers'},
-                [
-                  ['#content', language.$('misc.skippers.skipToContent')],
-                  sidebarLeftHTML &&
-                    [
-                      '#sidebar-left',
-                      sidebarRightHTML
-                        ? language.$('misc.skippers.skipToSidebar.left')
-                        : language.$('misc.skippers.skipToSidebar'),
-                    ],
-                  sidebarRightHTML &&
-                    [
-                      '#sidebar-right',
-                      sidebarLeftHTML
-                        ? language.$('misc.skippers.skipToSidebar.right')
-                        : language.$('misc.skippers.skipToSidebar'),
-                    ],
-                  footerHTML &&
-                    ['#footer', language.$('misc.skippers.skipToFooter')],
-                ]
-                  .filter(Boolean)
-                  .map(([href, title]) =>
-                    html.tag('span', {class: 'skipper'},
-                      html.tag('a', {href}, title)))),
+            skippersHTML,
             layoutHTML,
           ]),