« get me outta code hell

content: adapt "random pages" to wikis without dividing groups - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/content/dependencies/listRandomPageLinks.js
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2023-10-29 09:51:01 -0300
committer(quasar) nebula <qznebula@protonmail.com>2023-10-29 09:51:01 -0300
commitd2903c800b6a005a447cc26f9431fe5fe4fb08b6 (patch)
tree8662ccc98c6ff2e2d65162835ae3cae13498694b /src/content/dependencies/listRandomPageLinks.js
parent777fbd3535f80fb8fb28d80a5dc53efe44c6cb82 (diff)
content: adapt "random pages" to wikis without dividing groups
Diffstat (limited to 'src/content/dependencies/listRandomPageLinks.js')
-rw-r--r--src/content/dependencies/listRandomPageLinks.js40
1 files changed, 22 insertions, 18 deletions
diff --git a/src/content/dependencies/listRandomPageLinks.js b/src/content/dependencies/listRandomPageLinks.js
index 57ecb04..ce90a15 100644
--- a/src/content/dependencies/listRandomPageLinks.js
+++ b/src/content/dependencies/listRandomPageLinks.js
@@ -1,33 +1,36 @@
+import {empty} from '#sugar';
+
 export default {
   contentDependencies: [
     'generateListingPage',
+    'generateListRandomPageLinksAllAlbumsSection',
     'generateListRandomPageLinksGroupSection',
   ],
 
   extraDependencies: ['html', 'language', 'wikiData'],
 
-  sprawl({wikiInfo}) {
-    return {wikiInfo};
-  },
+  sprawl: ({wikiInfo}) => ({wikiInfo}),
 
-  query(sprawl, spec) {
-    return {
-      spec,
+  query: ({wikiInfo: {divideTrackListsByGroups: groups}}, spec) => ({
+    spec,
+    groups,
+    divideByGroups: !empty(groups),
+  }),
 
-      groups:
-        sprawl.wikiInfo.divideTrackListsByGroups,
-    };
-  },
+  relations: (relation, query) => ({
+    page: relation('generateListingPage', query.spec),
 
-  relations(relation, query) {
-    return {
-      page: relation('generateListingPage', query.spec),
+    allAlbumsSection:
+      (query.divideByGroups
+        ? null
+        : relation('generateListRandomPageLinksAllAlbumsSection')),
 
-      groupSections:
-        query.groups
-          .map(group => relation('generateListRandomPageLinksGroupSection', group)),
-    };
-  },
+    groupSections:
+      (query.divideByGroups
+        ? query.groups
+            .map(group => relation('generateListRandomPageLinksGroupSection', group))
+        : null),
+  }),
 
   generate(relations, {html, language}) {
     return relations.page.slots({
@@ -73,6 +76,7 @@ export default {
                   language.$('listingPage.other.randomPages.misc.randomTrackWholeSite'))),
             ])),
 
+          relations.allAlbumsSection,
           relations.groupSections,
         ]),
       ],