From 07059614fb0e5b64950b21abdd46b99deb481dfd Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Thu, 1 Jan 2026 15:13:51 -0400 Subject: content: getContentEntryTotals --- src/content/dependencies/getContentEntryTotals.js | 29 +++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/content/dependencies/getContentEntryTotals.js (limited to 'src/content/dependencies/getContentEntryTotals.js') diff --git a/src/content/dependencies/getContentEntryTotals.js b/src/content/dependencies/getContentEntryTotals.js new file mode 100644 index 00000000..ce590887 --- /dev/null +++ b/src/content/dependencies/getContentEntryTotals.js @@ -0,0 +1,29 @@ +import multilingualWordCount from 'word-count'; + +import {accumulateSum} from '#sugar'; + +export default { + relations: (relation, entries) => ({ + bodies: + entries + .map(entry => relation('transformContent', entry.body)), + }), + + data: (entries) => ({ + entries: + entries.length, + }), + + generate: (data, relations, {html}) => ({ + entryCount: + data.entries, + + wordCount: + accumulateSum( + relations.bodies.flatMap(body => + multilingualWordCount( + html.resolve( + body.slot('mode', 'multiline'), + {normalize: 'plain'})))), + }), +}; \ No newline at end of file -- cgit 1.3.0-6-gf8a5