« get me outta code hell

content: cut html.template boilerplate - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/content/dependencies/generateCoverGrid.js
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2023-06-12 16:35:38 -0300
committer(quasar) nebula <qznebula@protonmail.com>2023-06-12 16:35:38 -0300
commit535acb34613b5cf7e22654619f4337b94b70644d (patch)
tree5a713eb4f12eae7e1fe1aa60941709708585db32 /src/content/dependencies/generateCoverGrid.js
parent630af0a345f3be6c3e4aa3300ce138e48ed5ae91 (diff)
content: cut html.template boilerplate
Diffstat (limited to 'src/content/dependencies/generateCoverGrid.js')
-rw-r--r--src/content/dependencies/generateCoverGrid.js68
1 files changed, 31 insertions, 37 deletions
diff --git a/src/content/dependencies/generateCoverGrid.js b/src/content/dependencies/generateCoverGrid.js
index fdd9f8b7..a024ae25 100644
--- a/src/content/dependencies/generateCoverGrid.js
+++ b/src/content/dependencies/generateCoverGrid.js
@@ -1,44 +1,38 @@
 export default {
   extraDependencies: ['html'],
 
-  generate({html}) {
-    return html.template({
-      annotation: `generateCoverGrid`,
+  slots: {
+    images: {validate: v => v.arrayOf(v.isHTML)},
+    links: {validate: v => v.arrayOf(v.isHTML)},
+    names: {validate: v => v.arrayOf(v.isString)},
 
-      slots: {
-        images: {validate: v => v.arrayOf(v.isHTML)},
-        links: {validate: v => v.arrayOf(v.isHTML)},
-        names: {validate: v => v.arrayOf(v.isString)},
-
-        lazy: {validate: v => v.oneOf(v.isWholeNumber, v.isBoolean)},
-      },
+    lazy: {validate: v => v.oneOf(v.isWholeNumber, v.isBoolean)},
+  },
 
-      content(slots) {
-        return (
-          html.tag('div', {class: 'grid-listing'},
-            slots.images.map((image, i) => {
-              const link = slots.links[i];
-              const name = slots.names[i];
-              return link.slots({
-                content: [
-                  image.slots({
-                    thumb: 'medium',
-                    lazy:
-                      (typeof slots.lazy === 'number'
-                        ? i >= slots.lazy
-                     : typeof slots.lazy === 'boolean'
-                        ? slots.lazy
-                        : false),
-                    square: true,
-                  }),
-                  html.tag('span', name),
-                ],
-                attributes: {
-                  class: ['grid-item', 'box', /* large && 'large-grid-item' */],
-                },
-              });
-            })));
-      },
-    });
+  generate(slots, {html}) {
+    return (
+      html.tag('div', {class: 'grid-listing'},
+        slots.images.map((image, i) => {
+          const link = slots.links[i];
+          const name = slots.names[i];
+          return link.slots({
+            content: [
+              image.slots({
+                thumb: 'medium',
+                lazy:
+                  (typeof slots.lazy === 'number'
+                    ? i >= slots.lazy
+                 : typeof slots.lazy === 'boolean'
+                    ? slots.lazy
+                    : false),
+                square: true,
+              }),
+              html.tag('span', name),
+            ],
+            attributes: {
+              class: ['grid-item', 'box', /* large && 'large-grid-item' */],
+            },
+          });
+        })));
   },
 };