« get me outta code hell

content: listRandomPageLinks: show skip to section - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2023-11-09 16:40:18 -0400
committer(quasar) nebula <qznebula@protonmail.com>2023-11-09 16:40:18 -0400
commitf6a0bf1d7b4652a7dd04ed3340010ee2a6e47b7f (patch)
tree3ccfa46027b1dd3536e2b020943999767e46b7ab
parent082f693274a62c9f826fd84def417f243c21d612 (diff)
content: listRandomPageLinks: show skip to section
-rw-r--r--src/content/dependencies/generateListingPage.js2
-rw-r--r--src/content/dependencies/listRandomPageLinks.js21
2 files changed, 21 insertions, 2 deletions
diff --git a/src/content/dependencies/generateListingPage.js b/src/content/dependencies/generateListingPage.js
index b3d6899d..95c039eb 100644
--- a/src/content/dependencies/generateListingPage.js
+++ b/src/content/dependencies/generateListingPage.js
@@ -96,7 +96,7 @@ export default {
     },
 
     chunkIDs: {
-      validate: v => v.strictArrayOf(v.isString),
+      validate: v => v.strictArrayOf(v.optional(v.isString)),
     },
 
     listStyle: {
diff --git a/src/content/dependencies/listRandomPageLinks.js b/src/content/dependencies/listRandomPageLinks.js
index 089289f7..375a72d7 100644
--- a/src/content/dependencies/listRandomPageLinks.js
+++ b/src/content/dependencies/listRandomPageLinks.js
@@ -61,7 +61,19 @@ export default {
     return relations;
   },
 
-  generate(relations, {html, language}) {
+  data(query) {
+    const data = {};
+
+    if (query.divideByGroups) {
+      data.groupDirectories =
+        query.groups
+          .map(group => group.directory);
+    }
+
+    return data;
+  },
+
+  generate(data, relations, {html, language}) {
     const miscellaneousChunkRows = [
       {
         stringsKey: 'randomArtist',
@@ -111,6 +123,13 @@ export default {
           language.$('listingPage.other.randomPages.dataLoadedLine')),
       ],
 
+      showSkipToSection: true,
+
+      chunkIDs: [
+        null,
+        ...data.groupDirectories,
+      ],
+
       chunkTitles: [
         {stringsKey: 'misc'},