« 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
diff options
context:
space:
mode:
Diffstat (limited to 'src/content')
-rw-r--r--src/content/dependencies/generateArtistInfoPageArtworksChunk.js22
-rw-r--r--src/content/dependencies/generateArtistInfoPageArtworksChunkItem.js14
-rw-r--r--src/content/dependencies/generateArtistInfoPageArtworksChunkedList.js12
-rw-r--r--src/content/dependencies/generateArtistInfoPageChunk.js10
-rw-r--r--src/content/dependencies/generateArtistInfoPageChunkItem.js19
5 files changed, 40 insertions, 37 deletions
diff --git a/src/content/dependencies/generateArtistInfoPageArtworksChunk.js b/src/content/dependencies/generateArtistInfoPageArtworksChunk.js
index 2b10df3e..66e4204a 100644
--- a/src/content/dependencies/generateArtistInfoPageArtworksChunk.js
+++ b/src/content/dependencies/generateArtistInfoPageArtworksChunk.js
@@ -5,6 +5,8 @@ export default {
     'linkAlbum',
   ],
 
+  extraDependencies: ['html'],
+
   relations: (relation, album, contribs) => ({
     template:
       relation('generateArtistInfoPageChunk'),
@@ -24,11 +26,25 @@ export default {
         .map(contrib => contrib.date),
   }),
 
-  generate: (data, relations) =>
+  slots: {
+    filterEditsForWiki: {
+      type: 'boolean',
+      default: false,
+    },
+  },
+
+  generate: (data, relations, slots) =>
     relations.template.slots({
       mode: 'album',
       albumLink: relations.albumLink,
-      dates: data.dates,
-      items: relations.items,
+
+      dates:
+        (slots.filterEditsForWiki
+          ? Array.from({length: data.dates}, () => null)
+          : data.dates),
+
+      items:
+        relations.items.map(item =>
+          item.slot('filterEditsForWiki', slots.filterEditsForWiki)),
     }),
 };
diff --git a/src/content/dependencies/generateArtistInfoPageArtworksChunkItem.js b/src/content/dependencies/generateArtistInfoPageArtworksChunkItem.js
index e8d887b1..089cfb8d 100644
--- a/src/content/dependencies/generateArtistInfoPageArtworksChunkItem.js
+++ b/src/content/dependencies/generateArtistInfoPageArtworksChunkItem.js
@@ -39,11 +39,21 @@ export default {
       contrib.annotation,
   }),
 
-  generate: (data, relations, {html, language}) =>
+  slots: {
+    filterEditsForWiki: {
+      type: 'boolean',
+      default: false,
+    },
+  },
+
+  generate: (data, relations, slots, {html, language}) =>
     relations.template.slots({
       otherArtistLinks: relations.otherArtistLinks,
 
-      annotation: data.annotation,
+      annotation:
+        (slots.filterEditsForWiki
+          ? data.annotation?.replace(/^edits for wiki(: )?/, '')
+          : data.annotation),
 
       content:
         language.encapsulate('artistPage.creditList.entry', capsule =>
diff --git a/src/content/dependencies/generateArtistInfoPageArtworksChunkedList.js b/src/content/dependencies/generateArtistInfoPageArtworksChunkedList.js
index 2be02577..8b024147 100644
--- a/src/content/dependencies/generateArtistInfoPageArtworksChunkedList.js
+++ b/src/content/dependencies/generateArtistInfoPageArtworksChunkedList.js
@@ -65,15 +65,7 @@ export default {
   generate: (data, relations) =>
     relations.chunkedList.slots({
       chunks:
-        relations.chunks.map(chunk => {
-          if (data.filterEditsForWiki) {
-            chunk.setSlots({
-              trimAnnotations: true,
-              dates: [],
-            });
-          }
-
-          return chunk;
-        }),
+        relations.chunks.map(chunk =>
+          chunk.slot('filterEditsForWiki', data.filterEditsForWiki)),
     }),
 };
diff --git a/src/content/dependencies/generateArtistInfoPageChunk.js b/src/content/dependencies/generateArtistInfoPageChunk.js
index 820c01e0..c16d50f3 100644
--- a/src/content/dependencies/generateArtistInfoPageChunk.js
+++ b/src/content/dependencies/generateArtistInfoPageChunk.js
@@ -29,11 +29,6 @@ export default {
 
     duration: {validate: v => v.isDuration},
     durationApproximate: {type: 'boolean'},
-
-    trimAnnotations: {
-      type: 'boolean',
-      default: false,
-    },
   },
 
   generate(slots, {html, language}) {
@@ -107,10 +102,7 @@ export default {
       html.tag('dt', accentedLink),
       html.tag('dd',
         html.tag('ul',
-          slots.items
-            .map(item => item.slots({
-              trimAnnotation: slots.trimAnnotations,
-            })))),
+          slots.items)),
     ]);
   },
 };
diff --git a/src/content/dependencies/generateArtistInfoPageChunkItem.js b/src/content/dependencies/generateArtistInfoPageChunkItem.js
index 0ec7b1ec..9d406c67 100644
--- a/src/content/dependencies/generateArtistInfoPageChunkItem.js
+++ b/src/content/dependencies/generateArtistInfoPageChunkItem.js
@@ -9,18 +9,16 @@ export default {
       mutable: false,
     },
 
-    annotation: {type: 'string'},
+    annotation: {
+      type: 'html',
+      mutable: false,
+    },
 
     otherArtistLinks: {
       validate: v => v.strictArrayOf(v.isHTML),
     },
 
     rerelease: {type: 'boolean'},
-
-    trimAnnotation: {
-      type: 'boolean',
-      default: false,
-    },
   },
 
   generate: (slots, {html, language}) =>
@@ -45,15 +43,10 @@ export default {
               language.formatConjunctionList(slots.otherArtistLinks);
           }
 
-          const annotation =
-            (slots.trimAnnotation
-              ? slots.annotation?.replace(/^edits for wiki(: )?/, '')
-              : slots.annotation);
-
-          if (annotation) {
+          if (!html.isBlank(slots.annotation)) {
             anyAccent = true;
             workingCapsule += '.withAnnotation';
-            workingOptions.annotation = annotation;
+            workingOptions.annotation = slots.annotation;
           }
 
           if (anyAccent) {