diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2023-07-27 16:31:46 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2023-07-27 16:31:46 -0300 |
commit | 6712dd4d178af643e6961fdfad86a66339b722b5 (patch) | |
tree | 056120b4b9e0d30632245bff40c8fa76debcf1c9 /src/content/dependencies | |
parent | df93623c48f9ce32fe7fac8344512836f7fe345b (diff) |
content: generateListingPage: support custom strings subkeys
Diffstat (limited to 'src/content/dependencies')
-rw-r--r-- | src/content/dependencies/generateListingPage.js | 23 |
1 files changed, 18 insertions, 5 deletions
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' && |