« get me outta code hell

content: generateArtTagSidebar: list current tag's descendants - 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-10-06 00:53:46 -0300
committer(quasar) nebula <qznebula@protonmail.com>2023-10-06 00:53:46 -0300
commitedd386577c6c04366cce646eb1674b4e2b41525a (patch)
tree0741db624e81de2930d503ab0cfaebb0bfabe771 /src
parent48284df1091b10dfcc19eb6858e55bc254800407 (diff)
content: generateArtTagSidebar: list current tag's descendants
Diffstat (limited to 'src')
-rw-r--r--src/content/dependencies/generateArtTagSidebar.js29
1 files changed, 25 insertions, 4 deletions
diff --git a/src/content/dependencies/generateArtTagSidebar.js b/src/content/dependencies/generateArtTagSidebar.js
index b5b4ced3..f6787a8c 100644
--- a/src/content/dependencies/generateArtTagSidebar.js
+++ b/src/content/dependencies/generateArtTagSidebar.js
@@ -1,4 +1,4 @@
-import {stitchArrays} from '#sugar';
+import {empty, stitchArrays} from '#sugar';
 import {collectTreeLeaves} from '#wiki-data';
 
 export default {
@@ -25,7 +25,13 @@ export default {
   },
 
   relations: (relation, query, sprawl, artTag) => ({
-    artTagLink: relation('linkArtTagDynamically', artTag),
+    artTagLink:
+      relation('linkArtTagDynamically', artTag),
+
+    directDescendantArtTagLinks:
+      artTag.directDescendantArtTags
+        .map(descendantArtTag =>
+          relation('linkArtTagDynamically', descendantArtTag)),
 
     furthestAncestorArtTagMapLists:
       query.furthestAncestorArtTags
@@ -35,7 +41,9 @@ export default {
             artTag)),
   }),
 
-  data: query => ({
+  data: (query, sprawl, artTag) => ({
+    name: artTag.name,
+
     furthestAncestorArtTagNames:
       query.furthestAncestorArtTags
         .map(ancestorArtTag => ancestorArtTag.name),
@@ -46,6 +54,17 @@ export default {
       html.tag('h1',
         relations.artTagLink),
 
+      !empty(relations.directDescendantArtTagLinks) &&
+        html.tag('details', {class: 'current', open: true}, [
+          html.tag('summary',
+            html.tag('span', {class: 'group-name'},
+              language.sanitize(data.name))),
+
+          html.tag('ul',
+            relations.directDescendantArtTagLinks
+              .map(link => html.tag('li', link))),
+        ]),
+
       stitchArrays({
         name: data.furthestAncestorArtTagNames,
         list: relations.furthestAncestorArtTagMapLists,
@@ -53,7 +72,9 @@ export default {
           html.tag('details',
             {
               class: 'has-tree-list',
-              open: relations.furthestAncestorArtTagMapLists.length === 1,
+              open:
+                empty(relations.directDescendantArtTagLinks) &&
+                relations.furthestAncestorArtTagMapLists.length === 1,
             },
             [
               html.tag('summary',