From 9fb4baa667f76c51abc0c6469d95351f90266a6a Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Fri, 4 Jun 2021 16:27:15 -0300 Subject: module-ify tag pages --- src/page/index.js | 3 ++- src/page/tag.js | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 src/page/tag.js (limited to 'src/page') diff --git a/src/page/index.js b/src/page/index.js index 101a168..f580cbe 100644 --- a/src/page/index.js +++ b/src/page/index.js @@ -47,6 +47,7 @@ export * as flash from './flash.js'; export * as group from './group.js'; export * as homepage from './homepage.js'; export * as listing from './listing.js'; -export * as static from './static.js'; export * as news from './news.js'; +export * as static from './static.js'; +export * as tag from './tag.js'; export * as track from './track.js'; diff --git a/src/page/tag.js b/src/page/tag.js new file mode 100644 index 0000000..c6f64bf --- /dev/null +++ b/src/page/tag.js @@ -0,0 +1,76 @@ +// Art tag page specification. + +// Imports + +import fixWS from 'fix-whitespace'; + +import { + getThemeString +} from '../util/colors.js'; + +// Page exports + +export function condition({wikiData}) { + return wikiData.wikiInfo.features.artTagUI; +} + +export function targets({wikiData}) { + return wikiData.tagData.filter(tag => !tag.isCW); +} + +export function write(tag, {wikiData}) { + const { wikiInfo } = wikiData; + const { things } = tag; + + const page = { + type: 'page', + path: ['tag', tag.directory], + page: ({ + getAlbumCover, + getGridHTML, + getTrackCover, + link, + strings, + to + }) => ({ + title: strings('tagPage.title', {tag: tag.name}), + theme: getThemeString(tag.color), + + main: { + classes: ['top-index'], + content: fixWS` +

${strings('tagPage.title', {tag: tag.name})}

+

${strings('tagPage.infoLine', { + coverArts: strings.count.coverArts(things.length, {unit: true}) + })}

+
+ ${getGridHTML({ + entries: things.map(item => ({item})), + srcFn: thing => (thing.album + ? getTrackCover(thing) + : getAlbumCover(thing)), + hrefFn: thing => (thing.album + ? to('localized.track', thing.directory) + : to('localized.album', thing.directory)) + })} +
+ ` + }, + + nav: { + links: [ + {toHome: true}, + wikiInfo.features.listings && + { + path: ['localized.listingIndex'], + title: strings('listingIndex.title') + }, + {toCurrentPage: true} + ] + } + }) + }; + + return [page]; +} + -- cgit 1.3.0-6-gf8a5