« get me outta code hell

content: generateListingPage: add chunkRowAttributes slot - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/content/dependencies/generateListingPage.js
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2023-11-09 15:48:36 -0400
committer(quasar) nebula <qznebula@protonmail.com>2023-11-09 15:48:36 -0400
commit443c2e42ad2731e63f40c9575e2c27001ed55bae (patch)
treea1d6964eba172d7725ab1319eb26954561ffdca5 /src/content/dependencies/generateListingPage.js
parent150c414044662134ddf785e7411560e3a6051a03 (diff)
content: generateListingPage: add chunkRowAttributes slot
This refactors out the hard-coded 'rerelease' behavior.
Diffstat (limited to 'src/content/dependencies/generateListingPage.js')
-rw-r--r--src/content/dependencies/generateListingPage.js24
1 files changed, 18 insertions, 6 deletions
diff --git a/src/content/dependencies/generateListingPage.js b/src/content/dependencies/generateListingPage.js
index 45b7dc1b..403f891f 100644
--- a/src/content/dependencies/generateListingPage.js
+++ b/src/content/dependencies/generateListingPage.js
@@ -68,6 +68,7 @@ export default {
 
     chunkTitles: {validate: v => v.strictArrayOf(v.isObject)},
     chunkRows: {validate: v => v.strictArrayOf(v.isObject)},
+    chunkRowAttributes: {validate: v => v.strictArrayOf(v.optional(v.isObject))},
 
     showSkipToSection: {type: 'boolean', default: false},
     chunkIDs: {validate: v => v.strictArrayOf(v.isString)},
@@ -165,9 +166,17 @@ export default {
 
             stitchArrays({
               title: slots.chunkTitles,
-              rows: slots.chunkRows,
               id: slots.chunkIDs,
-            }).map(({title, rows, id}) => [
+
+              rows: slots.chunkRows,
+              rowAttributes: slots.chunkRowAttributes,
+            }).map(({
+                title,
+                id,
+
+                rows,
+                rowAttributes,
+              }) => [
                 relations.chunkHeading
                   .clone()
                   .slots({
@@ -178,10 +187,13 @@ export default {
 
                 html.tag('dd',
                   html.tag(listTag,
-                    rows.map(row =>
-                      html.tag('li',
-                        {class: row.stringsKey === 'rerelease' && 'rerelease'},
-                        formatListingString('chunk.item', row))))),
+                    stitchArrays({
+                      row: rows,
+                      attributes: rowAttributes ?? rows.map(() => null),
+                    }).map(({row, attributes}) =>
+                        html.tag('li',
+                          attributes,
+                          formatListingString('chunk.item', row))))),
               ]),
           ]),
       ],