« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/content/dependencies/generateNewsEntryPage.js66
-rw-r--r--src/data/things/language.js1
-rw-r--r--src/static/site6.css5
-rw-r--r--src/strings-default.yaml6
4 files changed, 74 insertions, 4 deletions
diff --git a/src/content/dependencies/generateNewsEntryPage.js b/src/content/dependencies/generateNewsEntryPage.js
index 62d6bb7b..c8db9f35 100644
--- a/src/content/dependencies/generateNewsEntryPage.js
+++ b/src/content/dependencies/generateNewsEntryPage.js
@@ -53,12 +53,18 @@ export default {
         relation('generatePreviousNextLinks');
 
       if (query.previousEntry) {
-        relations.previousEntryLink =
+        relations.previousEntryNavLink =
+          relation('linkNewsEntry', query.previousEntry);
+
+        relations.previousEntryContentLink =
           relation('linkNewsEntry', query.previousEntry);
       }
 
       if (query.nextEntry) {
-        relations.nextEntryLink =
+        relations.nextEntryNavLink =
+          relation('linkNewsEntry', query.nextEntry);
+
+        relations.nextEntryContentLink =
           relation('linkNewsEntry', query.nextEntry);
       }
     }
@@ -70,6 +76,20 @@ export default {
     return {
       name: newsEntry.name,
       date: newsEntry.date,
+
+      daysSincePreviousEntry:
+        query.previousEntry &&
+          Math.round((newsEntry.date - query.previousEntry.date) / 86400000),
+
+      daysUntilNextEntry:
+        query.nextEntry &&
+          Math.round((query.nextEntry.date - newsEntry.date) / 86400000),
+
+      previousEntryDate:
+        query.previousEntry?.date,
+
+      nextEntryDate:
+        query.nextEntry?.date,
     };
   },
 
@@ -90,6 +110,44 @@ export default {
           })),
 
         relations.content,
+
+        html.tag('p', {
+          [html.onlyIfContent]: true,
+          [html.joinChildren]: html.tag('br'),
+          class: 'read-another-links',
+        }, [
+          relations.previousEntryContentLink &&
+            language.$('newsEntryPage.readAnother.previous', {
+              entry: relations.previousEntryContentLink,
+
+              date:
+                html.tag('span',
+                  {
+                    title:
+                      language.$('newsEntryPage.readAnother.earlier', {
+                        time:
+                          language.countDays(data.daysSincePreviousEntry, {unit: true}),
+                      }).toString(),
+                  },
+                  language.formatDate(data.previousEntryDate)),
+            }),
+
+          relations.nextEntryContentLink &&
+            language.$('newsEntryPage.readAnother.next', {
+              entry: relations.nextEntryContentLink,
+
+              date:
+                html.tag('span',
+                  {
+                    title:
+                      language.$('newsEntryPage.readAnother.later', {
+                        time:
+                          language.countDays(data.daysUntilNextEntry, {unit: true}),
+                      }).toString(),
+                  },
+                  language.formatDate(data.nextEntryDate)),
+            }),
+        ]),
       ],
 
       navLinkStyle: 'hierarchical',
@@ -101,8 +159,8 @@ export default {
           accent:
             (relations.previousNextLinks
               ? `(${language.formatUnitList(relations.previousNextLinks.slots({
-                  previousLink: relations.previousEntryLink ?? null,
-                  nextLink: relations.nextEntryLink ?? null,
+                  previousLink: relations.previousEntryNavLink ?? null,
+                  nextLink: relations.nextEntryNavLink ?? null,
                 }).content)})`
               : null),
         },
diff --git a/src/data/things/language.js b/src/data/things/language.js
index 80a34575..c1916313 100644
--- a/src/data/things/language.js
+++ b/src/data/things/language.js
@@ -542,6 +542,7 @@ Object.assign(Language.prototype, {
   countAdditionalFiles: countHelper('additionalFiles', 'files'),
   countAlbums: countHelper('albums'),
   countArtworks: countHelper('artworks'),
+  countDays: countHelper('days'),
   countFlashes: countHelper('flashes'),
   countCommentaryEntries: countHelper('commentaryEntries', 'entries'),
   countContributions: countHelper('contributions'),
diff --git a/src/static/site6.css b/src/static/site6.css
index b2130222..3534e50d 100644
--- a/src/static/site6.css
+++ b/src/static/site6.css
@@ -935,6 +935,10 @@ html[data-url-key="localized.listing"][data-url-value0="random"] #content a:not(
   opacity: 0.7;
 }
 
+html[data-url-key="localized.newsEntry"] .read-another-links {
+  font-style: oblique;
+}
+
 /* Additional names (heading and box) */
 
 h1 a[href="#additional-names-box"] {
@@ -997,6 +1001,7 @@ h1 a[href="#additional-names-box"]:hover {
   display: inline-block;
 }
 
+>>>>>>> preview:src/static/site6.css
 /* Images */
 
 .image-container {
diff --git a/src/strings-default.yaml b/src/strings-default.yaml
index c15a8f5d..c812b330 100644
--- a/src/strings-default.yaml
+++ b/src/strings-default.yaml
@@ -1726,6 +1726,12 @@ newsEntryPage:
   title: "{ENTRY}"
   published: "(Published {DATE}.)"
 
+  readAnother:
+    previous: "(← {DATE} {ENTRY})"
+    next: "(→ {DATE} {ENTRY})"
+    earlier: "{TIME} earlier"
+    later: "{TIME} later"
+
 #
 # redirectPage:
 #   Static "placeholder" pages when redirecting a visitor from one