From edd386577c6c04366cce646eb1674b4e2b41525a Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Fri, 6 Oct 2023 00:53:46 -0300 Subject: content: generateArtTagSidebar: list current tag's descendants --- src/content/dependencies/generateArtTagSidebar.js | 29 +++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) (limited to 'src/content') 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', -- cgit 1.3.0-6-gf8a5