diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/content/dependencies/generateArtTagInfoPage.js | 155 | ||||
-rw-r--r-- | src/page/art-tag.js | 12 | ||||
-rw-r--r-- | src/strings-default.json | 4 |
3 files changed, 170 insertions, 1 deletions
diff --git a/src/content/dependencies/generateArtTagInfoPage.js b/src/content/dependencies/generateArtTagInfoPage.js new file mode 100644 index 00000000..f8354269 --- /dev/null +++ b/src/content/dependencies/generateArtTagInfoPage.js @@ -0,0 +1,155 @@ +import {empty, unique} from '#sugar'; + +export default { + contentDependencies: [ + 'generateArtTagNavLinks', + 'generateContentHeading', + 'generatePageLayout', + 'linkArtTag', + 'linkExternal', + 'transformContent', + ], + + extraDependencies: ['html', 'language', 'wikiData'], + + sprawl({wikiInfo}) { + return { + enableListings: wikiInfo.enableListings, + }; + }, + + query(sprawl, artTag) { + const directThings = artTag.directlyTaggedInThings; + const indirectThings = artTag.indirectlyTaggedInThings; + const allThings = unique([...directThings, ...indirectThings]); + + return {directThings, indirectThings, allThings}; + }, + + relations(relation, query, sprawl, artTag) { + const relations = {}; + const sec = relations.sections = {}; + + relations.layout = + relation('generatePageLayout'); + + relations.navLinks = + relation('generateArtTagNavLinks', artTag); + + const info = sec.info = {}; + + if (artTag.description) { + info.description = + relation('transformContent', artTag.description); + } + + if (!empty(artTag.extraReadingURLs)) { + info.extraReadingLinks = + artTag.extraReadingURLs + .map(url => relation('linkExternal', url)); + } + + if (!empty(artTag.directAncestorArtTags)) { + const ancestors = sec.ancestors = {}; + + ancestors.heading = + relation('generateContentHeading'); + + ancestors.directAncestorLinks = + artTag.directAncestorArtTags + .map(artTag => relation('linkArtTag', artTag)); + } + + if (!empty(artTag.directDescendantArtTags)) { + const descendants = sec.descendants = {}; + + descendants.heading = + relation('generateContentHeading'); + + descendants.directDescendantLinks = + artTag.directDescendantArtTags + .map(artTag => relation('linkArtTag', artTag)); + } + + return relations; + }, + + data(query, sprawl, artTag) { + const data = {}; + + data.enableListings = sprawl.enableListings; + + data.name = artTag.name; + data.color = artTag.color; + + data.numArtworks = query.allThings.length; + + data.names = + query.allThings.map(thing => thing.name); + + data.paths = + 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; + }, + + generate(data, relations, {html, language}) { + const {sections: sec} = relations; + + return relations.layout + .slots({ + title: + language.$('artTagInfoPage.title', { + tag: data.name, + }), + + headingMode: 'static', + color: data.color, + + mainContent: [ + sec.info.extraReadingLinks && + html.tag('p', + language.$('releaseInfo.readMoreOn', { + links: language.formatDisjunctionList(sec.info.extraReadingLinks), + })), + + html.tag('blockquote', + {[html.onlyIfContent]: true}, + sec.info.description + ?.slot('mode', 'multiline')), + + sec.ancestors && [ + sec.ancestors.heading + .slot('title', language.$('artTagInfoPage.descendsFromTags', { + tag: language.sanitize(data.name), + })), + + html.tag('ul', + sec.ancestors.directAncestorLinks + .map(link => html.tag('li', link))), + ], + + sec.descendants && [ + sec.descendants.heading + .slot('title', language.$('artTagInfoPage.descendantTags', { + tag: language.sanitize(data.name), + })), + + html.tag('ul', + sec.descendants.directDescendantLinks + .map(link => html.tag('li', link))), + ], + ], + + navLinkStyle: 'hierarchical', + navLinks: relations.navLinks.content, + }); + }, +}; diff --git a/src/page/art-tag.js b/src/page/art-tag.js index 32e869e1..5b61229d 100644 --- a/src/page/art-tag.js +++ b/src/page/art-tag.js @@ -1,6 +1,6 @@ // Art tag page specification. -export const description = `per-art-tag gallery pages`; +export const description = `per-art-tag info & gallery pages`; export function condition({wikiData}) { return wikiData.wikiInfo.enableArtTagUI; @@ -14,6 +14,16 @@ export function pathsForTarget(tag) { return [ { type: 'page', + path: ['artTagInfo', tag.directory], + + contentFunction: { + name: 'generateArtTagInfoPage', + args: [tag], + }, + }, + + { + type: 'page', path: ['artTagGallery', tag.directory], contentFunction: { diff --git a/src/strings-default.json b/src/strings-default.json index 00177554..bed6d1a7 100644 --- a/src/strings-default.json +++ b/src/strings-default.json @@ -120,6 +120,7 @@ "releaseInfo.listenOn.noLinks": "This wiki doesn't have any listening links for {NAME}.", "releaseInfo.visitOn": "Visit on {LINKS}.", "releaseInfo.playOn": "Play on {LINKS}.", + "releaseInfo.readMoreOn": "Read more on {LINKS}.", "releaseInfo.readCommentary": "Read {LINK}.", "releaseInfo.readCommentary.link": "artist commentary", "releaseInfo.alsoReleasedAs": "Also released as:", @@ -320,6 +321,9 @@ "artistGalleryPage.title": "{ARTIST} - Gallery", "artistGalleryPage.infoLine": "Contributed to {COVER_ARTS}.", "artTagPage.nav.tag": "Tag: {TAG}", + "artTagInfoPage.title": "{TAG}", + "artTagInfoPage.descendantTags": "Tags that descend from {TAG}:", + "artTagInfoPage.descendsFromTags": "Tags that {TAG} descends from:", "artTagGalleryPage.title": "{TAG}", "artTagGalleryPage.infoLine": "Appears in {COVER_ARTS}.", "artTagGalleryPage.descendsFrom": "Descends from {TAGS}.", |