« 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/tag.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/page/tag.js')
-rw-r--r--src/page/tag.js99
1 files changed, 12 insertions, 87 deletions
diff --git a/src/page/tag.js b/src/page/tag.js
index da4f194..8942aea 100644
--- a/src/page/tag.js
+++ b/src/page/tag.js
@@ -1,5 +1,7 @@
 // Art tag page specification.
 
+export const description = `per-artwork-tag gallery pages`;
+
 export function condition({wikiData}) {
   return wikiData.wikiInfo.enableArtTagUI;
 }
@@ -8,93 +10,16 @@ export function targets({wikiData}) {
   return wikiData.artTagData.filter((tag) => !tag.isContentWarning);
 }
 
-export function write(tag, {wikiData}) {
-  const {taggedInThings: things} = tag;
-
-  // Display things featuring this art tag in reverse chronological order,
-  // sticking the most recent additions near the top!
-  const thingsReversed = things.slice().reverse();
-
-  const entries = thingsReversed.map((item) => ({item}));
-
-  const page = {
-    type: 'page',
-    path: ['tag', tag.directory],
-    page: ({
-      getAlbumCover,
-      getGridHTML,
-      getThemeString,
-      getTrackCover,
-      html,
-      language,
-      link,
-    }) => ({
-      title: language.$('tagPage.title', {tag: tag.name}),
-      theme: getThemeString(tag.color),
+export function pathsForTarget(tag) {
+  return [
+    {
+      type: 'page',
+      path: ['tag', tag.directory],
 
-      main: {
-        classes: ['top-index'],
-        content: [
-          html.tag('h1',
-            language.$('tagPage.title', {
-              tag: tag.name,
-            })),
-
-          html.tag('p',
-            {class: 'quick-info'},
-            language.$('tagPage.infoLine', {
-              coverArts: language.countCoverArts(things.length, {
-                unit: true,
-              }),
-            })),
-
-          html.tag('div',
-            {class: 'grid-listing'},
-            getGridHTML({
-              entries,
-              srcFn: (thing) =>
-                thing.album
-                  ? getTrackCover(thing)
-                  : getAlbumCover(thing),
-              linkFn: (thing, opts) =>
-                thing.album
-                  ? link.track(thing, opts)
-                  : link.album(thing, opts),
-            })),
-        ],
-      },
-
-      nav: generateTagNav(tag, {
-        link,
-        language,
-        wikiData,
-      }),
-    }),
-  };
-
-  return [page];
-}
-
-// Utility functions
-
-function generateTagNav(tag, {
-  language,
-  link,
-  wikiData,
-}) {
-  return {
-    linkContainerClasses: ['nav-links-hierarchy'],
-    links: [
-      {toHome: true},
-      wikiData.wikiInfo.enableListings && {
-        path: ['localized.listingIndex'],
-        title: language.$('listingIndex.title'),
-      },
-      {
-        html: language.$('tagPage.nav.tag', {
-          tag: link.tag(tag, {class: 'current'}),
-        }),
+      contentFunction: {
+        name: 'generateArtTagGalleryPage',
+        args: [tag],
       },
-    ],
-  };
+    },
+  ];
 }