« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/page
diff options
context:
space:
mode:
Diffstat (limited to 'src/page')
-rw-r--r--src/page/tag.js51
1 files changed, 40 insertions, 11 deletions
diff --git a/src/page/tag.js b/src/page/tag.js
index 39bfda60..9ef3d8c3 100644
--- a/src/page/tag.js
+++ b/src/page/tag.js
@@ -28,6 +28,7 @@ export function write(tag, {wikiData}) {
         type: 'page',
         path: ['tag', tag.directory],
         page: ({
+            generatePreviousNextLinks,
             getAlbumCover,
             getGridHTML,
             getThemeString,
@@ -60,20 +61,48 @@ export function write(tag, {wikiData}) {
                 `
             },
 
-            nav: {
-                links: [
-                    {toHome: true},
-                    wikiInfo.features.listings &&
-                    {
-                        path: ['localized.listingIndex'],
-                        title: strings('listingIndex.title')
-                    },
-                    {toCurrentPage: true}
-                ]
-            }
+            nav: generateTagNav(tag, {
+                generatePreviousNextLinks,
+                link,
+                strings,
+                wikiData
+            })
         })
     };
 
     return [page];
 }
 
+// Utility functions
+
+function generateTagNav(tag, {
+    generatePreviousNextLinks,
+    link,
+    strings,
+    wikiData
+}) {
+    const previousNextLinks = generatePreviousNextLinks(tag, {
+        data: wikiData.tagData.filter(tag => !tag.isCW),
+        linkKey: 'tag'
+    });
+
+    return {
+        links: [
+            {toHome: true},
+            wikiData.wikiInfo.features.listings &&
+            {
+                path: ['localized.listingIndex'],
+                title: strings('listingIndex.title')
+            },
+            {
+                html: strings('tagPage.nav.tag', {
+                    tag: link.tag(tag, {class: 'current'})
+                })
+            },
+            previousNextLinks && {
+                divider: false,
+                html: `(${previousNextLinks})`
+            }
+        ]
+    };
+}