« 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
diff options
context:
space:
mode:
Diffstat (limited to 'src/content/dependencies')
-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',