« get me outta code hell

content: use stitchArrays in various places - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/content/dependencies
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2023-06-23 20:01:21 -0300
committer(quasar) nebula <qznebula@protonmail.com>2023-06-23 20:01:21 -0300
commitc8332bb4e9b719eae0bc8f758ab1835ea1b4d0e8 (patch)
tree12476c2eee53d6ed95b9f63f16818e66ac13c7a1 /src/content/dependencies
parent89e79008b02331b69660bb16b6ca737e37483e61 (diff)
content: use stitchArrays in various places
Diffstat (limited to 'src/content/dependencies')
-rw-r--r--src/content/dependencies/generateAlbumCommentaryPage.js24
-rw-r--r--src/content/dependencies/generateAlbumGalleryPage.js20
-rw-r--r--src/content/dependencies/generateArtistGalleryPage.js10
3 files changed, 32 insertions, 22 deletions
diff --git a/src/content/dependencies/generateAlbumCommentaryPage.js b/src/content/dependencies/generateAlbumCommentaryPage.js
index 15d43a32..ea31292c 100644
--- a/src/content/dependencies/generateAlbumCommentaryPage.js
+++ b/src/content/dependencies/generateAlbumCommentaryPage.js
@@ -1,3 +1,5 @@
+import {stitchArrays} from '../../util/sugar.js';
+
 export default {
   contentDependencies: [
     'generateAlbumNavAccent',
@@ -127,18 +129,20 @@ export default {
               relations.albumCommentaryContent),
           ],
 
-          relations.trackCommentaryContent.map((commentaryContent, i) => [
-            relations.trackCommentaryHeadings[i]
-              .slots({
+          stitchArrays({
+            heading: relations.trackCommentaryHeadings,
+            link: relations.trackCommentaryLinks,
+            directory: data.trackCommentaryDirectories,
+            content: relations.trackCommentaryContent,
+            colorVariables: relations.trackCommentaryColorVariables,
+          }).map(({heading, link, directory, content, colorVariables}) => [
+              heading.slots({
                 tag: 'h3',
-                id: data.trackCommentaryDirectories[i],
-                title: relations.trackCommentaryLinks[i],
+                id: directory,
+                title: link,
               }),
-
-            html.tag('blockquote',
-              {style: relations.trackCommentaryColorVariables[i]},
-              relations.trackCommentaryContent[i]),
-          ]),
+              html.tag('blockquote', {style: colorVariables}, content),
+            ]),
         ],
 
         navLinkStyle: 'hierarchical',
diff --git a/src/content/dependencies/generateAlbumGalleryPage.js b/src/content/dependencies/generateAlbumGalleryPage.js
index 354c8401..71cd477b 100644
--- a/src/content/dependencies/generateAlbumGalleryPage.js
+++ b/src/content/dependencies/generateAlbumGalleryPage.js
@@ -1,3 +1,5 @@
+import {stitchArrays} from '../../util/sugar.js';
+
 export default {
   contentDependencies: [
     'generateAlbumGalleryInfoLine',
@@ -89,14 +91,16 @@ export default {
               links: relations.links,
               names: data.names,
               images:
-                relations.images.map((image, i) =>
-                  image.slots({
-                    path: data.paths[i],
-                    missingSourceContent:
-                      language.$('misc.albumGalleryGrid.noCoverArt', {
-                        name: data.names[i],
-                      }),
-                  })),
+                stitchArrays({
+                  image: relations.images,
+                  path: data.paths,
+                  name: data.names,
+                }).map(({image, path, name}) =>
+                    image.slots({
+                      path,
+                      missingSourceContent:
+                        language.$('misc.albumGalleryGrid.noCoverArt', {name}),
+                    })),
             }),
         ],
 
diff --git a/src/content/dependencies/generateArtistGalleryPage.js b/src/content/dependencies/generateArtistGalleryPage.js
index 41758d59..d1ec3efe 100644
--- a/src/content/dependencies/generateArtistGalleryPage.js
+++ b/src/content/dependencies/generateArtistGalleryPage.js
@@ -1,3 +1,4 @@
+import {stitchArrays} from '../../util/sugar.js';
 import {sortAlbumsTracksChronologically} from '../../util/wiki-data.js';
 
 // TODO: Very awkward we have to duplicate this functionality in relations and data.
@@ -92,10 +93,11 @@ export default {
               links: relations.links,
               names: data.names,
               images:
-                relations.images.map((image, i) =>
-                  image.slots({
-                    path: data.paths[i],
-                  })),
+                stitchArrays({
+                  image: relations.images,
+                  path: data.paths,
+                }).map(({image, path}) =>
+                    image.slot('path', path)),
             }),
         ],