« get me outta code hell

content: generateArtTagInfoPage: descendant gallery links - 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:
author(quasar) nebula <qznebula@protonmail.com>2023-10-06 00:55:16 -0300
committer(quasar) nebula <qznebula@protonmail.com>2023-10-06 00:55:16 -0300
commite327490387c97c79fd63abc88cfee115679499ac (patch)
tree3943bf66358451fa7b92d850dfdc833efaf869e3 /src/content
parent5285c0c896e89314e961b0f6261bc9bcda2813bd (diff)
content: generateArtTagInfoPage: descendant gallery links
Diffstat (limited to 'src/content')
-rw-r--r--src/content/dependencies/generateArtTagInfoPage.js46
1 files changed, 40 insertions, 6 deletions
diff --git a/src/content/dependencies/generateArtTagInfoPage.js b/src/content/dependencies/generateArtTagInfoPage.js
index be25cd97..056d9749 100644
--- a/src/content/dependencies/generateArtTagInfoPage.js
+++ b/src/content/dependencies/generateArtTagInfoPage.js
@@ -1,4 +1,4 @@
-import {empty, unique} from '#sugar';
+import {empty, stitchArrays, unique} from '#sugar';
 
 export default {
   contentDependencies: [
@@ -76,9 +76,19 @@ export default {
       descendants.heading =
         relation('generateContentHeading');
 
-      descendants.directDescendantLinks =
+      descendants.directDescendantInfoLinks =
         artTag.directDescendantArtTags
           .map(artTag => relation('linkArtTagInfo', artTag));
+
+      const allDescendantsHaveMoreDescendants =
+        artTag.directDescendantArtTags
+          .every(artTag => !empty(artTag.directDescendantArtTags));
+
+      if (!allDescendantsHaveMoreDescendants) {
+        descendants.directDescendantGalleryLinks =
+          artTag.directDescendantArtTags
+            .map(artTag => relation('linkArtTagGallery', artTag));
+      }
     }
 
     return relations;
@@ -167,7 +177,11 @@ export default {
 
             html.tag('ul',
               sec.ancestors.directAncestorLinks
-                .map(link => html.tag('li', link))),
+                .map(link =>
+                  html.tag('li',
+                    language.$('artTagInfoPage.descendsFromTags.item', {
+                      tag: link,
+                    })))),
           ],
 
           sec.descendants && [
@@ -175,9 +189,29 @@ export default {
               .slot('title',
                 language.$('artTagInfoPage.descendantTags', nameOption)),
 
-            html.tag('ul',
-              sec.descendants.directDescendantLinks
-                .map(link => html.tag('li', link))),
+            !sec.descendants.directDescendantGalleryLinks &&
+              html.tag('ul',
+                sec.descendants.directDescendantInfoLinks
+                  .map(link =>
+                    html.tag('li',
+                      language.$('artTagInfoPage.descendantTags.item', {
+                        tag: link,
+                      })))),
+
+            sec.descendants.directDescendantGalleryLinks &&
+              html.tag('ul',
+                stitchArrays({
+                  infoLink: sec.descendants.directDescendantInfoLinks,
+                  galleryLink: sec.descendants.directDescendantGalleryLinks,
+                }).map(({infoLink, galleryLink}) =>
+                    html.tag('li',
+                      language.$('artTagInfoPage.descendantTags.item.withGallery', {
+                        tag: infoLink,
+
+                        gallery:
+                          galleryLink.slot('content',
+                            language.$('artTagInfoPage.descendantTags.item.gallery')),
+                      })))),
           ],
         ],