From 377a9804116e8931e6335a0e0f1025b06d15cf69 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Thu, 27 Jul 2023 12:44:24 -0300 Subject: content: generateListingsIndexPage Also remove a bunch of reference code. --- .../dependencies/generateListingsIndexPage.js | 89 ++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 src/content/dependencies/generateListingsIndexPage.js (limited to 'src/content/dependencies') diff --git a/src/content/dependencies/generateListingsIndexPage.js b/src/content/dependencies/generateListingsIndexPage.js new file mode 100644 index 00000000..6887c6c2 --- /dev/null +++ b/src/content/dependencies/generateListingsIndexPage.js @@ -0,0 +1,89 @@ +import {getTotalDuration} from '../../util/wiki-data.js'; + +export default { + contentDependencies: [ + 'generateListingIndexList', + 'generateListingSidebar', + 'generatePageLayout', + ], + + extraDependencies: ['html', 'language', 'wikiData'], + + sprawl({albumData, trackData, wikiInfo}) { + return { + wikiName: wikiInfo.name, + numTracks: trackData.length, + numAlbums: albumData.length, + totalDuration: getTotalDuration(trackData), + }; + }, + + relations(relation) { + const relations = {}; + + relations.layout = + relation('generatePageLayout'); + + relations.sidebar = + relation('generateListingSidebar', null); + + relations.list = + relation('generateListingIndexList', null); + + return relations; + }, + + data(sprawl) { + return { + wikiName: sprawl.wikiName, + numTracks: sprawl.numTracks, + numAlbums: sprawl.numAlbums, + totalDuration: sprawl.totalDuration, + }; + }, + + generate(data, relations, {html, language}) { + return relations.layout.slots({ + title: language.$('listingIndex.title'), + + headingMode: 'static', + + mainContent: [ + html.tag('p', + language.$('listingIndex.infoLine', { + wiki: data.wikiName, + + tracks: + html.tag('b', + language.countTracks(data.numTracks, {unit: true})), + + albums: + html.tag('b', + language.countAlbums(data.numAlbums, {unit: true})), + + duration: + html.tag('b', + language.formatDuration(data.totalDuration, { + approximate: true, + unit: true, + })), + })), + + html.tag('hr'), + + html.tag('p', + language.$('listingIndex.exploreList')), + + relations.list.slot('mode', 'content'), + ], + + navLinkStyle: 'hierarchical', + navLinks: [ + {auto: 'home'}, + {auto: 'current'}, + ], + + ...relations.sidebar, + }); + }, +}; -- cgit 1.3.0-6-gf8a5