diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2023-10-02 19:34:53 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2024-06-13 16:49:40 -0300 |
commit | d9010438838feac2d26ca35ed9fc2c08604a85b5 (patch) | |
tree | 66486d7151c92cdb3789ea37c4b94ee17c2ab5f3 /src/content/dependencies/generateQuickDescription.js | |
parent | eb1bae12e2ea7021536909c43ce21f93691ccfbe (diff) |
content: generateQuickDescription
Diffstat (limited to 'src/content/dependencies/generateQuickDescription.js')
-rw-r--r-- | src/content/dependencies/generateQuickDescription.js | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/content/dependencies/generateQuickDescription.js b/src/content/dependencies/generateQuickDescription.js new file mode 100644 index 00000000..3dadfbcf --- /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', + mutable: true, + }, + }, + + generate: (data, relations, slots, {html, language}) => + html.tag('p', {class: 'quick-info'}, + {[html.joinChildren]: html.tag('br')}, + {[html.onlyIfContent]: true}, + + [ + relations.description?.slot('mode', 'inline'), + + data.hasLongerDescription && + slots.infoPageLink && + language.$('misc.quickDescription.moreInfo', { + link: + slots.infoPageLink + .slot('content', language.$('misc.quickDescription.moreInfo.link')), + }), + ]), +}; |