« get me outta code hell

content: generateCommentaryEntry: date ranges, date kinds - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/content
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2024-06-21 20:50:07 -0300
committer(quasar) nebula <qznebula@protonmail.com>2024-06-23 22:15:00 -0300
commit818f37ed334b2ab215a840c5b1cf5ee233a9d423 (patch)
treee96bae3463be4134786ec992a30d479ba21c9611 /src/content
parent4abfc0347a03e28eb954817bd84bf832840b6305 (diff)
content: generateCommentaryEntry: date ranges, date kinds
Diffstat (limited to 'src/content')
-rw-r--r--src/content/dependencies/generateCommentaryEntry.js36
1 files changed, 32 insertions, 4 deletions
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: