« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/content/dependencies/generateListRandomPageLinksAllAlbumsSection.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/content/dependencies/generateListRandomPageLinksAllAlbumsSection.js')
-rw-r--r--src/content/dependencies/generateListRandomPageLinksAllAlbumsSection.js35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/content/dependencies/generateListRandomPageLinksAllAlbumsSection.js b/src/content/dependencies/generateListRandomPageLinksAllAlbumsSection.js
new file mode 100644
index 00000000..e03252c9
--- /dev/null
+++ b/src/content/dependencies/generateListRandomPageLinksAllAlbumsSection.js
@@ -0,0 +1,35 @@
+import {sortChronologically} from '#wiki-data';
+
+export default {
+  contentDependencies: ['generateListRandomPageLinksAlbumLink', 'linkGroup'],
+  extraDependencies: ['html', 'language', 'wikiData'],
+
+  sprawl: ({albumData}) => ({albumData}),
+
+  query: (sprawl) => ({
+    albums:
+      sortChronologically(sprawl.albumData.slice())
+        .filter(album => album.tracks.length > 1),
+  }),
+
+  relations: (relation, query) => ({
+    albumLinks:
+      query.albums
+        .map(album => relation('generateListRandomPageLinksAlbumLink', album)),
+  }),
+
+  generate: (relations, {html, language}) =>
+    html.tags([
+      html.tag('dt',
+        language.$('listingPage.other.randomPages.fromAlbum')),
+
+      html.tag('dd',
+        html.tag('ul',
+          relations.albumLinks
+            .map(albumLink =>
+              html.tag('li',
+                language.$('listingPage.other.randomPages.album', {
+                  album: albumLink,
+                }))))),
+    ]),
+};