diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2023-10-02 19:07:34 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2023-10-02 19:07:34 -0300 |
commit | 835a4b6b069552450565970b6151b822e30575c5 (patch) | |
tree | 3a1e1221b56cccb4de3b3ad7d4b60c80f625fdf3 /src/content/dependencies | |
parent | 7de691cb628c78440dee9781eee01ca7753d8be2 (diff) |
content: generateArtTagGalleryPage: misc. additions & updates
Diffstat (limited to 'src/content/dependencies')
-rw-r--r-- | src/content/dependencies/generateArtTagGalleryPage.js | 83 |
1 files changed, 72 insertions, 11 deletions
diff --git a/src/content/dependencies/generateArtTagGalleryPage.js b/src/content/dependencies/generateArtTagGalleryPage.js index c04bfb68..a60d1a5d 100644 --- a/src/content/dependencies/generateArtTagGalleryPage.js +++ b/src/content/dependencies/generateArtTagGalleryPage.js @@ -1,4 +1,4 @@ -import {stitchArrays} from '#sugar'; +import {empty, stitchArrays, unique} from '#sugar'; import {sortAlbumsTracksChronologically} from '#wiki-data'; export default { @@ -9,6 +9,7 @@ export default { 'linkAlbum', 'linkArtTag', 'linkTrack', + 'transformContent', ], extraDependencies: ['html', 'language', 'wikiData'], @@ -20,14 +21,16 @@ export default { }, query(sprawl, tag) { - const things = tag.taggedInThings.slice(); + const directThings = tag.directlyTaggedInThings; + const indirectThings = tag.indirectlyTaggedInThings; + const allThings = unique([...directThings, ...indirectThings]); - sortAlbumsTracksChronologically(things, { - getDate: thing => thing.coverArtDate, + sortAlbumsTracksChronologically(allThings, { + getDate: thing => thing.coverArtDate ?? thing.date, latestFirst: true, }); - return {things}; + return {directThings, indirectThings, allThings}; }, relations(relation, query, sprawl, tag) { @@ -39,17 +42,38 @@ export default { relations.artTagMainLink = relation('linkArtTag', tag); + // TODO: linkArtTagInfo + relations.infoPageLink = + relation('linkArtTag', tag); + + if (tag.descriptionShort) { + relations.description = + relation('transformContent', tag.descriptionShort); + } + + if (!empty(tag.directAncestorTags)) { + relations.ancestorLinks = + tag.directAncestorTags.map(tag => + relation('linkArtTag', tag)); + } + + if (!empty(tag.directDescendantTags)) { + relations.descendantLinks = + tag.directDescendantTags.map(tag => + relation('linkArtTag', tag)); + } + relations.coverGrid = relation('generateCoverGrid'); relations.links = - query.things.map(thing => + query.allThings.map(thing => (thing.album ? relation('linkTrack', thing) : relation('linkAlbum', thing))); relations.images = - query.things.map(thing => + query.allThings.map(thing => relation('image', thing.artTags)); return relations; @@ -62,18 +86,23 @@ export default { data.name = tag.name; data.color = tag.color; + data.hasLongerDescription = tag.descriptionShort !== tag.description; - data.numArtworks = query.things.length; + data.numArtworks = query.allThings.length; data.names = - query.things.map(thing => thing.name); + query.allThings.map(thing => thing.name); data.paths = - query.things.map(thing => + query.allThings.map(thing => (thing.album ? ['media.trackCover', thing.album.directory, thing.directory, thing.coverArtFileExtension] : ['media.albumCover', thing.directory, thing.coverArtFileExtension])); + data.onlyFeaturedIndirectly = + query.allThings.map(thing => + !query.directThings.includes(thing)); + return data; }, @@ -92,17 +121,49 @@ export default { mainClasses: ['top-index'], mainContent: [ html.tag('p', - {class: 'quick-info'}, + { + [html.joinChildren]: html.tag('br'), + [html.onlyIfContent]: true, + class:' quick-info', + }, + [ + relations.description?.slot('mode', 'inline'), + data.hasLongerDescription && + language.$('tagPage.moreInfo', { + link: + relations.infoPageLink + .slot('content', language.$('tagPage.moreInfo.link')), + }), + ]), + + html.tag('p', {class: 'quick-info'}, language.$('tagPage.infoLine', { coverArts: language.countCoverArts(data.numArtworks, { unit: true, }), })), + relations.ancestorLinks && + html.tag('p', {class: 'quick-info'}, + language.$('tagPage.descendsFrom', { + tags: language.formatConjunctionList(relations.ancestorLinks), + })), + + relations.descendantLinks && + html.tag('p', {clasS: 'quick-info'}, + language.$('tagPage.desendants', { + tags: language.formatUnitList(relations.descendantLinks), + })), + relations.coverGrid .slots({ links: relations.links, names: data.names, + + classes: + data.onlyFeaturedIndirectly.map(onlyFeaturedIndirectly => + (onlyFeaturedIndirectly ? 'featured-indirectly' : '')), + images: stitchArrays({ image: relations.images, |