« get me outta code hell

show previous/next links in tag nav bar - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
diff options
context:
space:
mode:
author(quasar) nebula <towerofnix@gmail.com>2021-06-10 16:57:02 -0300
committer(quasar) nebula <towerofnix@gmail.com>2021-06-10 16:57:02 -0300
commit4b04056f18555824dde09914553fde71ad2e009b (patch)
tree581d54a1c08769bd9fe9c566eef8c6501ec04bf6
parent3318ceb4b7685abeaa2daec111ef503feacaefd9 (diff)
show previous/next links in tag nav bar
-rw-r--r--src/page/tag.js51
-rwxr-xr-xsrc/upd8.js2
2 files changed, 42 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})`
+            }
+        ]
+    };
+}
diff --git a/src/upd8.js b/src/upd8.js
index 8652f65c..e2a5b734 100755
--- a/src/upd8.js
+++ b/src/upd8.js
@@ -2449,6 +2449,8 @@ async function main() {
         }
     }
 
+    WD.tagData.sort(sortByName);
+
     WD.groupData = await processGroupDataFile(path.join(dataPath, GROUP_DATA_FILE));
     if (WD.groupData.error) {
         console.log(`\x1b[31;1m${WD.groupData.error}\x1b[0m`);