« get me outta code hell

content: generateListingPage: fix row-based listings... oops... - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2023-11-10 17:47:44 -0400
committer(quasar) nebula <qznebula@protonmail.com>2023-11-10 17:47:44 -0400
commitad943caefcacf62347199a73a90dc704cd8e369c (patch)
treed620106e99611eca95d16de33a464eb94ae272b1 /src
parent2de59682e52cd9121e53aec94a27ba78a09abb3e (diff)
content: generateListingPage: fix row-based listings... oops...
Diffstat (limited to 'src')
-rw-r--r--src/content/dependencies/generateListingPage.js23
1 files changed, 16 insertions, 7 deletions
diff --git a/src/content/dependencies/generateListingPage.js b/src/content/dependencies/generateListingPage.js
index 95c039eb..2050d62d 100644
--- a/src/content/dependencies/generateListingPage.js
+++ b/src/content/dependencies/generateListingPage.js
@@ -1,4 +1,4 @@
-import {empty, stitchArrays} from '#sugar';
+import {bindOpts, empty, stitchArrays} from '#sugar';
 
 export default {
   contentDependencies: [
@@ -130,29 +130,33 @@ export default {
       return language.formatString(...parts, options);
     }
 
-    const formatRow = ({row, attributes}) =>
+    const formatRow = ({context, row, attributes}) =>
       (attributes?.href
         ? html.tag('li',
             html.tag('a',
               attributes,
               formatListingString({
-                context: 'chunk.item',
+                context,
                 provided: row,
               })))
         : html.tag('li',
             attributes,
             formatListingString({
-              context: 'chunk.item',
+              context,
               provided: row,
             })));
 
-    const formatRowList = ({rows, rowAttributes}) =>
+    const formatRowList = ({context, rows, rowAttributes}) =>
       html.tag(
         (slots.listStyle === 'ordered' ? 'ol' : 'ul'),
         stitchArrays({
           row: rows,
           attributes: rowAttributes ?? rows.map(() => null),
-        }).map(formatRow));
+        }).map(
+          bindOpts(formatRow, {
+            [bindOpts.bindIndex]: 0,
+            context,
+          })));
 
     return relations.layout.slots({
       title: formatListingString({context: 'title'}),
@@ -188,6 +192,7 @@ export default {
 
         slots.type === 'rows' &&
           formatRowList({
+            context: 'item',
             rows: slots.rows,
             rowAttributes: slots.rowAttributes,
           }),
@@ -248,7 +253,11 @@ export default {
                   }),
 
                 html.tag('dd',
-                  formatRowList({rows, rowAttributes})),
+                  formatRowList({
+                    context: 'chunk.item',
+                    rows,
+                    rowAttributes,
+                  })),
               ]),
           ]),
       ],