From 818f37ed334b2ab215a840c5b1cf5ee233a9d423 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Fri, 21 Jun 2024 20:50:07 -0300 Subject: content: generateCommentaryEntry: date ranges, date kinds --- .../dependencies/generateCommentaryEntry.js | 36 +++++++++++++++++++--- 1 file changed, 32 insertions(+), 4 deletions(-) (limited to 'src/content') diff --git a/src/content/dependencies/generateCommentaryEntry.js b/src/content/dependencies/generateCommentaryEntry.js index f7f04f16..c148d244 100644 --- a/src/content/dependencies/generateCommentaryEntry.js +++ b/src/content/dependencies/generateCommentaryEntry.js @@ -45,6 +45,9 @@ export default { data: (entry) => ({ date: entry.date, + secondDate: entry.secondDate, + dateKind: entry.dateKind, + accessDate: entry.accessDate, accessKind: entry.accessKind, }), @@ -113,11 +116,36 @@ export default { {class: 'text-with-tooltip-interaction-cue'}, {[html.onlyIfContent]: true}, - language.$(titleCapsule, 'date', { - [language.onlyIfOptions]: ['date'], + language.encapsulate(titleCapsule, 'date', workingCapsule => { + const workingOptions = {}; + + if (!data.date) { + return html.blank(); + } + + const rangeNeeded = + data.dateKind === 'sometime' || + data.dateKind === 'throughout'; + + if (rangeNeeded && !data.secondDate) { + workingOptions.date = language.formatDate(data.date); + return language.$(workingCapsule, workingOptions); + } + + if (data.dateKind) { + workingCapsule += '.' + data.dateKind; + } + + if (data.secondDate) { + workingCapsule += '.range'; + workingOptions.dateRange = + language.formatDateRange(data.date, data.secondDate); + } else { + workingOptions.date = + language.formatDate(data.date); + } - date: - language.formatDate(data.date), + return language.$(workingCapsule, workingOptions); })), tooltip: -- cgit 1.3.0-6-gf8a5