From d9010438838feac2d26ca35ed9fc2c08604a85b5 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Mon, 2 Oct 2023 19:34:53 -0300 Subject: content: generateQuickDescription --- .../dependencies/generateGroupGalleryPage.js | 11 ++++++ .../dependencies/generateQuickDescription.js | 41 ++++++++++++++++++++++ src/strings-default.yaml | 5 +++ 3 files changed, 57 insertions(+) create mode 100644 src/content/dependencies/generateQuickDescription.js diff --git a/src/content/dependencies/generateGroupGalleryPage.js b/src/content/dependencies/generateGroupGalleryPage.js index d07847c6..6f23710d 100644 --- a/src/content/dependencies/generateGroupGalleryPage.js +++ b/src/content/dependencies/generateGroupGalleryPage.js @@ -10,8 +10,10 @@ export default { 'generateGroupSecondaryNav', 'generateGroupSidebar', 'generatePageLayout', + 'generateQuickDescription', 'image', 'linkAlbum', + 'linkGroup', 'linkListing', ], @@ -55,6 +57,12 @@ export default { .map(album => relation('image', album.artTags)); } + relations.quickDescription = + relation('generateQuickDescription', group); + + relations.quickDescriptionInfoLink = + relation('linkGroup', group); + relations.coverGrid = relation('generateCoverGrid'); @@ -128,6 +136,9 @@ export default { image.slot('path', path)), }), + relations.quickDescription + .slot('infoPageLink', relations.quickDescriptionInfoLink), + html.tag('p', {class: 'quick-info'}, language.$('groupGalleryPage.infoLine', { tracks: 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')), + }), + ]), +}; diff --git a/src/strings-default.yaml b/src/strings-default.yaml index 9c429d46..c9152434 100644 --- a/src/strings-default.yaml +++ b/src/strings-default.yaml @@ -625,6 +625,11 @@ misc: missingLinkContent: "(Missing link content)" + quickDescription: + moreInfo: + _: "({LINK})" + link: "More info..." + # nav: # Generic navigational elements. These usually only appear in the # wiki's nav bar, at the top of the page. -- cgit 1.3.0-6-gf8a5