From 1df42ce749af7e62dac85566b2b260dddfd65db3 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Wed, 12 Jun 2024 15:05:21 -0300 Subject: content: generateFlashInfoPage: content function syntax cleanup --- src/content/dependencies/generateFlashInfoPage.js | 124 ++++++++-------------- 1 file changed, 45 insertions(+), 79 deletions(-) diff --git a/src/content/dependencies/generateFlashInfoPage.js b/src/content/dependencies/generateFlashInfoPage.js index eec32157..d6066a95 100644 --- a/src/content/dependencies/generateFlashInfoPage.js +++ b/src/content/dependencies/generateFlashInfoPage.js @@ -32,85 +32,52 @@ export default { return query; }, - relations(relation, query, flash) { - const relations = {}; - const sections = relations.sections = {}; + relations: (relation, query, flash) => ({ + layout: + relation('generatePageLayout'), - relations.layout = - relation('generatePageLayout'); + sidebar: + relation('generateFlashActSidebar', flash.act, flash), - relations.sidebar = - relation('generateFlashActSidebar', flash.act, flash); - - relations.externalLinks = + externalLinks: query.urls - .map(url => relation('linkExternal', url)); - - // TODO: Flashes always have cover art (#175) - /* eslint-disable-next-line no-constant-condition */ - if (true) { - relations.cover = - relation('generateFlashCoverArtwork', flash); - } - - // Section: navigation bar - - const nav = sections.nav = {}; - - nav.flashActLink = - relation('linkFlashAct', flash.act); - - nav.flashNavAccent = - relation('generateFlashNavAccent', flash); - - // Section: Featured tracks - - if (!empty(flash.featuredTracks)) { - const featuredTracks = sections.featuredTracks = {}; + .map(url => relation('linkExternal', url)), - featuredTracks.heading = - relation('generateContentHeading'); + cover: + relation('generateFlashCoverArtwork', flash), - featuredTracks.list = - relation('generateTrackList', flash.featuredTracks); - } + contentHeading: + relation('generateContentHeading'), - // Section: Contributors + flashActLink: + relation('linkFlashAct', flash.act), - if (!empty(flash.contributorContribs)) { - const contributors = sections.contributors = {}; + flashNavAccent: + relation('generateFlashNavAccent', flash), - contributors.heading = - relation('generateContentHeading'); + featuredTracksList: + relation('generateTrackList', flash.featuredTracks), - contributors.list = - relation('generateContributionList', flash.contributorContribs); - } + contributorContributionList: + relation('generateContributionList', flash.contributorContribs), - // Section: Artist commentary + artistCommentarySection: + relation('generateCommentarySection', flash.commentary), + }), - if (flash.commentary) { - sections.artistCommentary = - relation('generateCommentarySection', flash.commentary); - } - - return relations; - }, + data: (_query, flash) => ({ + name: + flash.name, - data(query, flash) { - const data = {}; + color: + flash.color, - data.name = flash.name; - data.color = flash.color; - data.date = flash.date; + date: + flash.date, + }), - return data; - }, - - generate(data, relations, {html, language}) { - const {sections: sec} = relations; - - return relations.layout.slots({ + generate: (data, relations, {html, language}) => + relations.layout.slots({ title: language.$('flashPage.title', { flash: data.name, @@ -147,7 +114,7 @@ export default { {[html.joinChildren]: html.tag('br')}, [ - sec.artistCommentary && + !html.isBlank(relations.artistCommentarySection) && language.$('releaseInfo.readCommentary', { link: html.tag('a', {href: '#artist-commentary'}, @@ -155,8 +122,8 @@ export default { }), ]), - sec.featuredTracks && [ - sec.featuredTracks.heading + html.tags([ + relations.contentHeading.clone() .slots({ attributes: {id: 'features'}, title: @@ -165,32 +132,31 @@ export default { }), }), - sec.featuredTracks.list, - ], + relations.featuredTracksList, + ]), - sec.contributors && [ - sec.contributors.heading + html.tags([ + relations.contentHeading.clone() .slots({ attributes: {id: 'contributors'}, title: language.$('releaseInfo.contributors'), }), - sec.contributors.list, - ], + relations.contributorContributionList, + ]), - sec.artistCommentary, + relations.artistCommentarySection, ], navLinkStyle: 'hierarchical', navLinks: [ {auto: 'home'}, - {html: sec.nav.flashActLink.slot('color', false)}, + {html: relations.flashActLink.slot('color', false)}, {auto: 'current'}, ], - navBottomRowContent: sec.nav.flashNavAccent, + navBottomRowContent: relations.flashNavAccent, leftSidebar: relations.sidebar, - }); - }, + }), }; -- cgit 1.3.0-6-gf8a5