diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2024-06-12 13:57:39 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2024-06-18 22:56:09 -0300 |
commit | bb41118cc61a0b54a83b6c8a1a936b8ec6bd0f5e (patch) | |
tree | 0eee103e8a587accfd20dd6bdc6f67b8ab1ad425 | |
parent | cc8f335f8333e5bd4355eaeb228588050796fce6 (diff) |
content: generateCommentarySection: blank if no entries
-rw-r--r-- | src/content/dependencies/generateCommentarySection.js | 14 |
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}) => |