From 9f9945232c01bd4f3c2afdd59a5fc4f661ed3f68 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Mon, 2 Oct 2023 19:34:53 -0300 Subject: content: move "quick description" into own fn, try on group page too --- .../dependencies/generateQuickDescription.js | 41 ++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 src/content/dependencies/generateQuickDescription.js (limited to 'src/content/dependencies/generateQuickDescription.js') diff --git a/src/content/dependencies/generateQuickDescription.js b/src/content/dependencies/generateQuickDescription.js new file mode 100644 index 00000000..136769ac --- /dev/null +++ b/src/content/dependencies/generateQuickDescription.js @@ -0,0 +1,41 @@ +export default { + contentDependencies: ['transformContent'], + extraDependencies: ['html', 'language'], + + relations: (relation, thing) => + ({description: + (thing.descriptionShort || thing.description + ? relation('transformContent', + thing.descriptionShort ?? thing.description) + : null)}), + + data: (thing) => + ({hasLongerDescription: + thing.description && + thing.descriptionShort && + thing.descriptionShort !== thing.description}), + + slots: { + infoPageLink: {type: 'html'}, + }, + + generate(data, relations, slots, {html, language}) { + return html.tag('p', + { + [html.joinChildren]: html.tag('br'), + [html.onlyIfContent]: true, + class:' quick-info', + }, + [ + relations.description?.slot('mode', 'inline'), + + data.hasLongerDescription && + slots.infoPageLink && + language.$('misc.quickDescription.moreInfo', { + link: + slots.infoPageLink + .slot('content', language.$('misc.quickDescription.moreInfo.link')), + }), + ]); + }, +}; -- cgit 1.3.0-6-gf8a5