« 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/generateArtistInfoPageCommentaryChunkedList.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/content/dependencies/generateArtistInfoPageCommentaryChunkedList.js')
-rw-r--r--src/content/dependencies/generateArtistInfoPageCommentaryChunkedList.js38
1 files changed, 27 insertions, 11 deletions
diff --git a/src/content/dependencies/generateArtistInfoPageCommentaryChunkedList.js b/src/content/dependencies/generateArtistInfoPageCommentaryChunkedList.js
index 72bbf1b6..88c5ed54 100644
--- a/src/content/dependencies/generateArtistInfoPageCommentaryChunkedList.js
+++ b/src/content/dependencies/generateArtistInfoPageCommentaryChunkedList.js
@@ -19,7 +19,7 @@ export default {
 
   extraDependencies: ['html', 'language'],
 
-  query(artist) {
+  query(artist, filterWikiEditorCommentary) {
     const processEntry = ({
       thing,
       entry,
@@ -43,6 +43,7 @@ export default {
         flash,
 
         annotation: entry.annotation,
+        annotationParts: entry.annotationParts,
       },
     });
 
@@ -87,6 +88,12 @@ export default {
         .flatMap(thing =>
           thing.commentary
             .filter(entry => entry.artists.includes(artist))
+
+            .filter(entry =>
+              (filterWikiEditorCommentary
+                ? entry.isWikiEditorCommentary
+                : !entry.isWikiEditorCommentary))
+
             .map(entry => processEntry({thing, entry})));
 
     const processAlbumEntries = ({albums}) =>
@@ -146,7 +153,7 @@ export default {
     return {chunks};
   },
 
-  relations: (relation, query) => ({
+  relations: (relation, query, _artist, filterWikiEditorCommentary) => ({
     chunks:
       query.chunks
         .map(() => relation('generateArtistInfoPageChunk')),
@@ -178,13 +185,16 @@ export default {
     itemAnnotations:
       query.chunks
         .map(({chunk}) => chunk
-          .map(({annotation}) =>
-            (annotation
-              ? relation('transformContent', annotation)
-              : null))),
+          .map(entry =>
+            relation('transformContent',
+              (filterWikiEditorCommentary
+                ? entry.annotationParts
+                    .filter(part => part !== 'wiki editor')
+                    .join(', ')
+                : entry.annotation)))),
   }),
 
-  data: (query) => ({
+  data: (query, _artist, _filterWikiEditorCommentary) => ({
     chunkTypes:
       query.chunks
         .map(({chunkType}) => chunkType),
@@ -197,6 +207,8 @@ export default {
 
   generate: (data, relations, {html, language}) =>
     html.tag('dl',
+      {[html.onlyIfContent]: true},
+
       stitchArrays({
         chunk: relations.chunks,
         chunkLink: relations.chunkLinks,
@@ -230,9 +242,10 @@ export default {
                     }).map(({item, link, annotation, type}) =>
                       item.slots({
                         annotation:
-                          (annotation
-                            ? annotation.slot('mode', 'inline')
-                            : null),
+                          annotation.slots({
+                            mode: 'inline',
+                            absorbPunctuationFollowingExternalLinks: false,
+                          }),
 
                         content:
                           (type === 'album'
@@ -254,7 +267,10 @@ export default {
                       item.slots({
                         annotation:
                           (annotation
-                            ? annotation.slot('mode', 'inline')
+                            ? annotation.slots({
+                                mode: 'inline',
+                                absorbPunctuationFollowingExternalLinks: false,
+                              })
                             : null),
 
                         content: