« 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/dependencies
diff options
context:
space:
mode:
Diffstat (limited to 'src/content/dependencies')
-rw-r--r--src/content/dependencies/generateArtistInfoPageFlashesChunkedList.js2
-rw-r--r--src/content/dependencies/generateFlashActNavAccent.js13
-rw-r--r--src/content/dependencies/generateFlashNavAccent.js13
-rw-r--r--src/content/dependencies/generateGroupSecondaryNav.js10
-rw-r--r--src/content/dependencies/generateNewsEntryPage.js9
5 files changed, 18 insertions, 29 deletions
diff --git a/src/content/dependencies/generateArtistInfoPageFlashesChunkedList.js b/src/content/dependencies/generateArtistInfoPageFlashesChunkedList.js
index 392b2782..799e8509 100644
--- a/src/content/dependencies/generateArtistInfoPageFlashesChunkedList.js
+++ b/src/content/dependencies/generateArtistInfoPageFlashesChunkedList.js
@@ -71,7 +71,7 @@ export default {
         query.chunks.map(({chunk}) => chunk[0].flash.date ?? null),
 
       lastDates:
-        query.chunks.map(({chunk}) => chunk[chunk.length - 1].flash.date ?? null),
+        query.chunks.map(({chunk}) => chunk.at(-1).flash.date ?? null),
 
       itemContributions:
         query.chunks.map(({chunk}) =>
diff --git a/src/content/dependencies/generateFlashActNavAccent.js b/src/content/dependencies/generateFlashActNavAccent.js
index 98504385..424948f9 100644
--- a/src/content/dependencies/generateFlashActNavAccent.js
+++ b/src/content/dependencies/generateFlashActNavAccent.js
@@ -1,4 +1,4 @@
-import {empty} from '#sugar';
+import {atOffset, empty} from '#sugar';
 
 export default {
   contentDependencies: [
@@ -17,17 +17,14 @@ export default {
     const flashActs =
       sprawl.flashActData;
 
-    const index = flashActs.indexOf(flashAct);
+    const index =
+      flashActs.indexOf(flashAct);
 
     const previousFlashAct =
-      (index > 0
-        ? flashActs[index - 1]
-        : null);
+      atOffset(flashActs, index, -1);
 
     const nextFlashAct =
-      (index < flashActs.length - 1
-        ? flashActs[index + 1]
-        : null);
+      atOffset(flashActs, index, +1);
 
     return {previousFlashAct, nextFlashAct};
   },
diff --git a/src/content/dependencies/generateFlashNavAccent.js b/src/content/dependencies/generateFlashNavAccent.js
index 57196d06..55e056dc 100644
--- a/src/content/dependencies/generateFlashNavAccent.js
+++ b/src/content/dependencies/generateFlashNavAccent.js
@@ -1,4 +1,4 @@
-import {empty} from '#sugar';
+import {atOffset, empty} from '#sugar';
 
 export default {
   contentDependencies: [
@@ -19,17 +19,14 @@ export default {
       sprawl.flashActData
         .flatMap(act => act.flashes);
 
-    const index = flashes.indexOf(flash);
+    const index =
+      flashes.indexOf(flash);
 
     const previousFlash =
-      (index > 0
-        ? flashes[index - 1]
-        : null);
+      atOffset(flashes, index, -1);
 
     const nextFlash =
-      (index < flashes.length - 1
-        ? flashes[index + 1]
-        : null);
+      atOffset(flashes, index, +1);
 
     return {previousFlash, nextFlash};
   },
diff --git a/src/content/dependencies/generateGroupSecondaryNav.js b/src/content/dependencies/generateGroupSecondaryNav.js
index c649e300..e9c7004d 100644
--- a/src/content/dependencies/generateGroupSecondaryNav.js
+++ b/src/content/dependencies/generateGroupSecondaryNav.js
@@ -1,3 +1,5 @@
+import {atOffset} from '#sugar';
+
 export default {
   contentDependencies: [
     'generateColorStyleAttribute',
@@ -23,14 +25,10 @@ export default {
 
     return {
       previousGroup:
-        (index > 0
-          ? groups[index - 1]
-          : null),
+        atOffset(groups, index, -1),
 
       nextGroup:
-        (index < groups.length - 1
-          ? groups[index + 1]
-          : null),
+        atOffset(groups, index, +1),
     };
   },
 
diff --git a/src/content/dependencies/generateNewsEntryPage.js b/src/content/dependencies/generateNewsEntryPage.js
index fbd4f609..fa4d68a8 100644
--- a/src/content/dependencies/generateNewsEntryPage.js
+++ b/src/content/dependencies/generateNewsEntryPage.js
@@ -1,3 +1,4 @@
+import {atOffset} from '#sugar';
 import {sortChronologically} from '#wiki-data';
 
 export default {
@@ -22,14 +23,10 @@ export default {
     const index = entries.indexOf(newsEntry);
 
     const previousEntry =
-      (index > 0
-        ? entries[index - 1]
-        : null);
+      atOffset(entries, index, -1);
 
     const nextEntry =
-      (index < entries.length - 1
-        ? entries[index + 1]
-        : null);
+      atOffset(entries, index, +1);
 
     return {previousEntry, nextEntry};
   },