From 6712dd4d178af643e6961fdfad86a66339b722b5 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Thu, 27 Jul 2023 16:31:46 -0300 Subject: content: generateListingPage: support custom strings subkeys --- src/content/dependencies/generateListingPage.js | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'src/content/dependencies') diff --git a/src/content/dependencies/generateListingPage.js b/src/content/dependencies/generateListingPage.js index af93954e..c1666599 100644 --- a/src/content/dependencies/generateListingPage.js +++ b/src/content/dependencies/generateListingPage.js @@ -79,8 +79,21 @@ export default { ? 'ol' : 'ul'); + const formatListingString = (contextStringsKey, options = {}) => { + const baseStringsKey = `listingPage.${data.stringsKey}`; + + const parts = [baseStringsKey, contextStringsKey]; + + if (options.stringsKey) { + parts.push(options.stringsKey); + delete options.stringsKey; + } + + return language.formatString(parts.join('.'), options); + }; + return relations.layout.slots({ - title: language.$(`listingPage.${data.stringsKey}.title`), + title: formatListingString('title'), headingMode: 'sticky', mainContent: [ @@ -112,7 +125,7 @@ export default { html.tag(listTag, slots.rows.map(row => html.tag('li', - language.$(`listingPage.${data.stringsKey}.item`, row)))), + formatListingString('item', row)))), slots.type === 'chunks' && html.tag('dl', @@ -124,15 +137,15 @@ export default { .clone() .slots({ tag: 'dt', - title: - language.$(`listingPage.${data.stringsKey}.chunk.title`, title), + title: formatListingString('chunk.title', title), }), html.tag('dd', html.tag(listTag, rows.map(row => html.tag('li', - language.$(`listingPage.${data.stringsKey}.chunk.item`, row))))), + {class: row.stringsKey === 'rerelease' && 'rerelease'}, + formatListingString('chunk.item', row))))), ])), slots.type === 'custom' && -- cgit 1.3.0-6-gf8a5