« get me outta code hell

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:
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: