« get me outta code hell

content: generateCommentarySection: blank if no entries - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/content/dependencies
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2024-06-12 13:57:39 -0300
committer(quasar) nebula <qznebula@protonmail.com>2024-06-12 17:32:57 -0300
commit29cfb4b7b5787d32c915843c3fdc1200bca9284e (patch)
tree13f75da534f8cb8662a6a12bc5be38a502c2871b /src/content/dependencies
parent261ee0fceb4f2c46bdcb027b473833a560fd6dbe (diff)
content: generateCommentarySection: blank if no entries
Diffstat (limited to 'src/content/dependencies')
-rw-r--r--src/content/dependencies/generateCommentarySection.js14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/content/dependencies/generateCommentarySection.js b/src/content/dependencies/generateCommentarySection.js
index 39727360..c5090660 100644
--- a/src/content/dependencies/generateCommentarySection.js
+++ b/src/content/dependencies/generateCommentarySection.js
@@ -1,3 +1,5 @@
+import {empty} from '#sugar';
+
 export default {
   contentDependencies: [
     'transformContent',
@@ -12,15 +14,17 @@ export default {
       relation('generateContentHeading'),
 
     entries:
-      entries.map(entry =>
-        relation('generateCommentaryEntry', entry)),
+      (entries
+        ? entries.map(entry =>
+            relation('generateCommentaryEntry', entry))
+        : []),
   }),
 
   data: (entries) => ({
     firstEntryIsDated:
-      (entries[0]
-        ? !!entries[0].date
-        : null),
+      (empty(entries)
+        ? null
+        : !!entries[0].date),
   }),
 
   generate: (data, relations, {html, language}) =>