From 1deb589b2e22d92f6488d259ce6196706f1515b1 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Mon, 26 Jun 2023 00:23:58 -0300 Subject: content: generateArtistInfoPage rewrite draft Rewriting a rewrite!? Say whaaaaat??? Sorry, the previous code didn't even come close to snuff. --- .../dependencies/generateArtistInfoPageChunk.js | 44 ++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 src/content/dependencies/generateArtistInfoPageChunk.js (limited to 'src/content/dependencies/generateArtistInfoPageChunk.js') diff --git a/src/content/dependencies/generateArtistInfoPageChunk.js b/src/content/dependencies/generateArtistInfoPageChunk.js new file mode 100644 index 00000000..121cf43d --- /dev/null +++ b/src/content/dependencies/generateArtistInfoPageChunk.js @@ -0,0 +1,44 @@ +export default { + extraDependencies: ['html', 'language'], + + slots: { + albumLink: {type: 'html'}, + + date: {validate: v => v.isDate}, + duration: {validate: v => v.isDuration}, + durationApproximate: {type: 'boolean'}, + + items: {type: 'html'}, + }, + + generate(slots, {html, language}) { + let accentedLink = slots.albumLink; + + accent: { + const options = {album: accentedLink}; + const parts = ['artistPage.creditList.album']; + + if (slots.date) { + parts.push('withDate'); + options.date = language.formatDate(slots.date); + } + + if (slots.duration) { + parts.push('withDuration'); + options.duration = + language.formatDuration(slots.duration, { + approximate: slots.durationApproximate, + }); + } + + accentedLink = language.formatString(parts.join('.'), options); + } + + return html.tags([ + html.tag('dt', accentedLink), + html.tag('dd', + html.tag('ul', + slots.items)), + ]); + }, +}; -- cgit 1.3.0-6-gf8a5