« 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/listing.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/page/listing.js')
-rw-r--r--src/page/listing.js104
1 files changed, 52 insertions, 52 deletions
diff --git a/src/page/listing.js b/src/page/listing.js
index 69fa4919..90415ded 100644
--- a/src/page/listing.js
+++ b/src/page/listing.js
@@ -1,5 +1,5 @@
-// @format
-//
+/** @format */
+
 // Listing page specification.
 //
 // The targets here are a bit different than for most pages: rather than data
@@ -12,36 +12,36 @@
 
 // Imports
 
-import fixWS from "fix-whitespace";
+import fixWS from 'fix-whitespace';
 
-import * as html from "../util/html.js";
+import * as html from '../util/html.js';
 
-import { getTotalDuration } from "../util/wiki-data.js";
+import {getTotalDuration} from '../util/wiki-data.js';
 
 // Page exports
 
-export function condition({ wikiData }) {
+export function condition({wikiData}) {
   return wikiData.wikiInfo.enableListings;
 }
 
-export function targets({ wikiData }) {
+export function targets({wikiData}) {
   return wikiData.listingSpec;
 }
 
-export function write(listing, { wikiData }) {
-  if (listing.condition && !listing.condition({ wikiData })) {
+export function write(listing, {wikiData}) {
+  if (listing.condition && !listing.condition({wikiData})) {
     return null;
   }
 
-  const { wikiInfo } = wikiData;
+  const {wikiInfo} = wikiData;
 
-  const data = listing.data ? listing.data({ wikiData }) : null;
+  const data = listing.data ? listing.data({wikiData}) : null;
 
   const page = {
-    type: "page",
-    path: ["listing", listing.directory],
+    type: 'page',
+    path: ['listing', listing.directory],
     page: (opts) => {
-      const { getLinkThemeString, link, language } = opts;
+      const {getLinkThemeString, link, language} = opts;
       const titleKey = `listingPage.${listing.stringsKey}.title`;
 
       return {
@@ -63,7 +63,7 @@ export function write(listing, { wikiData }) {
                                 ${data
                                   .map((item) => listing.row(item, opts))
                                   .map((row) => `<li>${row}</li>`)
-                                  .join("\n")}
+                                  .join('\n')}
                             </ul>
                         `
                         }
@@ -80,14 +80,14 @@ export function write(listing, { wikiData }) {
         },
 
         nav: {
-          linkContainerClasses: ["nav-links-hierarchy"],
+          linkContainerClasses: ['nav-links-hierarchy'],
           links: [
-            { toHome: true },
+            {toHome: true},
             {
-              path: ["localized.listingIndex"],
-              title: language.$("listingIndex.title"),
+              path: ['localized.listingIndex'],
+              title: language.$('listingIndex.title'),
             },
-            { toCurrentPage: true },
+            {toCurrentPage: true},
           ],
         },
       };
@@ -97,21 +97,21 @@ export function write(listing, { wikiData }) {
   return [page];
 }
 
-export function writeTargetless({ wikiData }) {
-  const { albumData, trackData, wikiInfo } = wikiData;
+export function writeTargetless({wikiData}) {
+  const {albumData, trackData, wikiInfo} = wikiData;
 
   const totalDuration = getTotalDuration(trackData);
 
   const page = {
-    type: "page",
-    path: ["listingIndex"],
-    page: ({ getLinkThemeString, language, link }) => ({
-      title: language.$("listingIndex.title"),
+    type: 'page',
+    path: ['listingIndex'],
+    page: ({getLinkThemeString, language, link}) => ({
+      title: language.$('listingIndex.title'),
 
       main: {
         content: fixWS`
-                    <h1>${language.$("listingIndex.title")}</h1>
-                    <p>${language.$("listingIndex.infoLine", {
+                    <h1>${language.$('listingIndex.title')}</h1>
+                    <p>${language.$('listingIndex.infoLine', {
                       wiki: wikiInfo.name,
                       tracks: `<b>${language.countTracks(trackData.length, {
                         unit: true,
@@ -125,7 +125,7 @@ export function writeTargetless({ wikiData }) {
                       })}</b>`,
                     })}</p>
                     <hr>
-                    <p>${language.$("listingIndex.exploreList")}</p>
+                    <p>${language.$('listingIndex.exploreList')}</p>
                     ${generateLinkIndexForListings(null, false, {
                       link,
                       language,
@@ -143,7 +143,7 @@ export function writeTargetless({ wikiData }) {
         }),
       },
 
-      nav: { simple: true },
+      nav: {simple: true},
     }),
   };
 
@@ -154,11 +154,11 @@ export function writeTargetless({ wikiData }) {
 
 function generateSidebarForListings(
   currentListing,
-  { getLinkThemeString, link, language, wikiData }
+  {getLinkThemeString, link, language, wikiData}
 ) {
   return fixWS`
-        <h1>${link.listingIndex("", {
-          text: language.$("listingIndex.title"),
+        <h1>${link.listingIndex('', {
+          text: language.$('listingIndex.title'),
         })}</h1>
         ${generateLinkIndexForListings(currentListing, true, {
           getLinkThemeString,
@@ -172,24 +172,24 @@ function generateSidebarForListings(
 function generateLinkIndexForListings(
   currentListing,
   forSidebar,
-  { getLinkThemeString, link, language, wikiData }
+  {getLinkThemeString, link, language, wikiData}
 ) {
-  const { listingTargetSpec, wikiInfo } = wikiData;
+  const {listingTargetSpec, wikiInfo} = wikiData;
 
   const filteredByCondition = listingTargetSpec
-    .map(({ listings, ...rest }) => ({
+    .map(({listings, ...rest}) => ({
       ...rest,
-      listings: listings.filter(({ condition: c }) => !c || c({ wikiData })),
+      listings: listings.filter(({condition: c}) => !c || c({wikiData})),
     }))
-    .filter(({ listings }) => listings.length > 0);
+    .filter(({listings}) => listings.length > 0);
 
   const genUL = (listings) =>
     html.tag(
-      "ul",
+      'ul',
       listings.map((listing) =>
         html.tag(
-          "li",
-          { class: [listing === currentListing && "current"] },
+          'li',
+          {class: [listing === currentListing && 'current']},
           link.listing(listing, {
             text: language.$(`listingPage.${listing.stringsKey}.title.short`),
           })
@@ -199,30 +199,30 @@ function generateLinkIndexForListings(
 
   if (forSidebar) {
     return filteredByCondition
-      .map(({ title, listings }) =>
+      .map(({title, listings}) =>
         html.tag(
-          "details",
+          'details',
           {
             open: !forSidebar || listings.includes(currentListing),
-            class: listings.includes(currentListing) && "current",
+            class: listings.includes(currentListing) && 'current',
           },
           [
             html.tag(
-              "summary",
-              { style: getLinkThemeString(wikiInfo.color) },
-              html.tag("span", { class: "group-name" }, title({ language }))
+              'summary',
+              {style: getLinkThemeString(wikiInfo.color)},
+              html.tag('span', {class: 'group-name'}, title({language}))
             ),
             genUL(listings),
           ]
         )
       )
-      .join("\n");
+      .join('\n');
   } else {
     return html.tag(
-      "dl",
-      filteredByCondition.flatMap(({ title, listings }) => [
-        html.tag("dt", title({ language })),
-        html.tag("dd", genUL(listings)),
+      'dl',
+      filteredByCondition.flatMap(({title, listings}) => [
+        html.tag('dt', title({language})),
+        html.tag('dd', genUL(listings)),
       ])
     );
   }