« get me outta code hell

content: generateQuickDescription - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/content
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2023-10-02 19:34:53 -0300
committer(quasar) nebula <qznebula@protonmail.com>2024-06-18 22:56:10 -0300
commit8d175b6dddd3502e379e79cdaa348ee725398a8e (patch)
tree0be09e98d4c35b1fdf815b01ec32bfb5aa8c5589 /src/content
parent113d63482157dea70f1615f40f3cc8fd43ddd8bf (diff)
content: generateQuickDescription
Diffstat (limited to 'src/content')
-rw-r--r--src/content/dependencies/generateGroupGalleryPage.js11
-rw-r--r--src/content/dependencies/generateQuickDescription.js41
2 files changed, 52 insertions, 0 deletions
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')),
+          }),
+      ]),
+};