From e327490387c97c79fd63abc88cfee115679499ac Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Fri, 6 Oct 2023 00:55:16 -0300 Subject: content: generateArtTagInfoPage: descendant gallery links --- src/content/dependencies/generateArtTagInfoPage.js | 46 +++++++++++++++++++--- src/strings-default.json | 6 ++- 2 files changed, 45 insertions(+), 7 deletions(-) (limited to 'src') 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')), + })))), ], ], diff --git a/src/strings-default.json b/src/strings-default.json index be8939b8..f12fbad2 100644 --- a/src/strings-default.json +++ b/src/strings-default.json @@ -336,8 +336,12 @@ "artTagInfoPage.featuredIn.directlyOnly": "This tag is featured in {ARTWORKS}.", "artTagInfoPage.featuredIn.indirectlyOnly": "This tag is featured in {ARTWORKS}, but only indirectly - have a look at its descendant tags!", "artTagInfoPage.featuredIn.directlyAndIndirectly": "This tag is directly featured in {ARTWORKS_DIRECTLY}, and indirectly in {ARTWORKS_INDIRECTLY} more, for a total of {ARTWORKS_TOTAL}.", - "artTagInfoPage.descendantTags": "Tags that descend from {TAG}:", "artTagInfoPage.descendsFromTags": "Tags that {TAG} descends from:", + "artTagInfoPage.descendsFromTags.item": "{TAG}", + "artTagInfoPage.descendantTags": "Tags that descend from {TAG}:", + "artTagInfoPage.descendantTags.item": "{TAG}", + "artTagInfoPage.descendantTags.item.withGallery": "{TAG} ({GALLERY})", + "artTagInfoPage.descendantTags.item.gallery": "Gallery", "artTagGalleryPage.title": "{TAG}", "artTagGalleryPage.infoLine": "Appears in {COVER_ARTS}.", "artTagGalleryPage.descendsFrom": "Descends from {TAGS}.", -- cgit 1.3.0-6-gf8a5