« get me outta code hell

real pragma, and some eslint fixes - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/page/flash.js
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2022-06-26 18:02:27 -0300
committer(quasar) nebula <qznebula@protonmail.com>2022-06-26 18:02:27 -0300
commitc75b029160248b6935e5c0f5156cc7a870311e82 (patch)
tree693c5cca195e50b048b0086e768aa06a7c1986ee /src/page/flash.js
parentf65e712fe8b8b1a196da2db286ebc6a5c9bf7433 (diff)
real pragma, and some eslint fixes
Diffstat (limited to 'src/page/flash.js')
-rw-r--r--src/page/flash.js160
1 files changed, 77 insertions, 83 deletions
diff --git a/src/page/flash.js b/src/page/flash.js
index 864f44d..340927d 100644
--- a/src/page/flash.js
+++ b/src/page/flash.js
@@ -1,29 +1,29 @@
-// @format
-//
+/** @format */
+
 // Flash page and index specifications.
 
 // 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 { getFlashLink } from "../util/wiki-data.js";
+import {getFlashLink} from '../util/wiki-data.js';
 
 // Page exports
 
-export function condition({ wikiData }) {
+export function condition({wikiData}) {
   return wikiData.wikiInfo.enableFlashesAndGames;
 }
 
-export function targets({ wikiData }) {
+export function targets({wikiData}) {
   return wikiData.flashData;
 }
 
-export function write(flash, { wikiData }) {
+export function write(flash, {wikiData}) {
   const page = {
-    type: "page",
-    path: ["flash", flash.directory],
+    type: 'page',
+    path: ['flash', flash.directory],
     page: ({
       fancifyFlashURL,
       generateChronologyLinks,
@@ -36,26 +36,26 @@ export function write(flash, { wikiData }) {
       language,
       transformInline,
     }) => ({
-      title: language.$("flashPage.title", { flash: flash.name }),
+      title: language.$('flashPage.title', {flash: flash.name}),
       theme: getThemeString(flash.color, [
         `--flash-directory: ${flash.directory}`,
       ]),
 
       main: {
         content: fixWS`
-                    <h1>${language.$("flashPage.title", {
+                    <h1>${language.$('flashPage.title', {
                       flash: flash.name,
                     })}</h1>
                     ${generateCoverLink({
                       src: getFlashCover(flash),
-                      alt: language.$("misc.alt.flashArt"),
+                      alt: language.$('misc.alt.flashArt'),
                     })}
-                    <p>${language.$("releaseInfo.released", {
+                    <p>${language.$('releaseInfo.released', {
                       date: language.formatDate(flash.date),
                     })}</p>
                     ${
                       (flash.page || flash.urls?.length) &&
-                      `<p>${language.$("releaseInfo.playOn", {
+                      `<p>${language.$('releaseInfo.playOn', {
                         links: language.formatDisjunctionList(
                           [
                             flash.page && getFlashLink(flash),
@@ -69,15 +69,15 @@ export function write(flash, { wikiData }) {
                       fixWS`
                         <p>Tracks featured in <i>${flash.name.replace(
                           /\.$/,
-                          ""
+                          ''
                         )}</i>:</p>
                         <ul>
                             ${flash.featuredTracks
                               .map((track) =>
-                                language.$("trackList.item.withArtists", {
+                                language.$('trackList.item.withArtists', {
                                   track: link.track(track),
                                   by: `<span class="by">${language.$(
-                                    "trackList.item.withArtists.by",
+                                    'trackList.item.withArtists.by',
                                     {
                                       artists: getArtistString(
                                         track.artistContribs
@@ -87,14 +87,14 @@ export function write(flash, { wikiData }) {
                                 })
                               )
                               .map((row) => `<li>${row}</li>`)
-                              .join("\n")}
+                              .join('\n')}
                         </ul>
                     `
                     }
                     ${
                       flash.contributorContribs.length &&
                       fixWS`
-                        <p>${language.$("releaseInfo.contributors")}</p>
+                        <p>${language.$('releaseInfo.contributors')}</p>
                         <ul>
                             ${flash.contributorContribs
                               .map(
@@ -104,14 +104,14 @@ export function write(flash, { wikiData }) {
                                     showIcons: true,
                                   })}</li>`
                               )
-                              .join("\n")}
+                              .join('\n')}
                         </ul>
                     `
                     }
                 `,
       },
 
-      sidebarLeft: generateSidebarForFlash(flash, { link, language, wikiData }),
+      sidebarLeft: generateSidebarForFlash(flash, {link, language, wikiData}),
       nav: generateNavForFlash(flash, {
         generateChronologyLinks,
         generatePreviousNextLinks,
@@ -125,32 +125,32 @@ export function write(flash, { wikiData }) {
   return [page];
 }
 
-export function writeTargetless({ wikiData }) {
-  const { flashActData } = wikiData;
+export function writeTargetless({wikiData}) {
+  const {flashActData} = wikiData;
 
   const page = {
-    type: "page",
-    path: ["flashIndex"],
-    page: ({ getFlashGridHTML, getLinkThemeString, link, language }) => ({
-      title: language.$("flashIndex.title"),
+    type: 'page',
+    path: ['flashIndex'],
+    page: ({getFlashGridHTML, getLinkThemeString, link, language}) => ({
+      title: language.$('flashIndex.title'),
 
       main: {
-        classes: ["flash-index"],
+        classes: ['flash-index'],
         content: fixWS`
-                    <h1>${language.$("flashIndex.title")}</h1>
+                    <h1>${language.$('flashIndex.title')}</h1>
                     <div class="long-content">
-                        <p class="quick-info">${language.$("misc.jumpTo")}</p>
+                        <p class="quick-info">${language.$('misc.jumpTo')}</p>
                         <ul class="quick-info">
                             ${flashActData
                               .filter((act) => act.jump)
                               .map(
-                                ({ anchor, jump, jumpColor }) => fixWS`
+                                ({anchor, jump, jumpColor}) => fixWS`
                                 <li><a href="#${anchor}" style="${getLinkThemeString(
                                   jumpColor
                                 )}">${jump}</a></li>
                             `
                               )
-                              .join("\n")}
+                              .join('\n')}
                         </ul>
                     </div>
                     ${flashActData
@@ -171,11 +171,11 @@ export function writeTargetless({ wikiData }) {
                         </div>
                     `
                       )
-                      .join("\n")}
+                      .join('\n')}
                 `,
       },
 
-      nav: { simple: true },
+      nav: {simple: true},
     }),
   };
 
@@ -186,32 +186,26 @@ export function writeTargetless({ wikiData }) {
 
 function generateNavForFlash(
   flash,
-  {
-    generateChronologyLinks,
-    generatePreviousNextLinks,
-    link,
-    language,
-    wikiData,
-  }
+  {generateChronologyLinks, generatePreviousNextLinks, link, language, wikiData}
 ) {
-  const { flashData, wikiInfo } = wikiData;
+  const {flashData, wikiInfo} = wikiData;
 
   const previousNextLinks = generatePreviousNextLinks(flash, {
     data: flashData,
-    linkKey: "flash",
+    linkKey: 'flash',
   });
 
   return {
-    linkContainerClasses: ["nav-links-hierarchy"],
+    linkContainerClasses: ['nav-links-hierarchy'],
     links: [
-      { toHome: true },
+      {toHome: true},
       {
-        path: ["localized.flashIndex"],
-        title: language.$("flashIndex.title"),
+        path: ['localized.flashIndex'],
+        title: language.$('flashIndex.title'),
       },
       {
-        html: language.$("flashPage.nav.flash", {
-          flash: link.flash(flash, { class: "current" }),
+        html: language.$('flashPage.nav.flash', {
+          flash: link.flash(flash, {class: 'current'}),
         }),
       },
     ],
@@ -221,8 +215,8 @@ function generateNavForFlash(
     content: fixWS`
             <div>
                 ${generateChronologyLinks(flash, {
-                  headingString: "misc.chronology.heading.flash",
-                  contribKey: "contributorContribs",
+                  headingString: 'misc.chronology.heading.flash',
+                  contribKey: 'contributorContribs',
                   getThings: (artist) => artist.flashesAsContributor,
                 })}
             </div>
@@ -230,21 +224,21 @@ function generateNavForFlash(
   };
 }
 
-function generateSidebarForFlash(flash, { link, language, wikiData }) {
+function generateSidebarForFlash(flash, {link, language, wikiData}) {
   // all hard-coded, sorry :(
   // this doesnt have a super portable implementation/design...yet!!
 
-  const { flashActData } = wikiData;
+  const {flashActData} = wikiData;
 
-  const act6 = flashActData.findIndex((act) => act.name.startsWith("Act 6"));
+  const act6 = flashActData.findIndex((act) => act.name.startsWith('Act 6'));
   const postCanon = flashActData.findIndex((act) =>
-    act.name.includes("Post Canon")
+    act.name.includes('Post Canon')
   );
   const outsideCanon =
     postCanon +
     flashActData
       .slice(postCanon)
-      .findIndex((act) => !act.name.includes("Post Canon"));
+      .findIndex((act) => !act.name.includes('Post Canon'));
   const actIndex = flashActData.indexOf(flash.act);
   const side =
     actIndex < 0 ? 0 : actIndex < act6 ? 1 : actIndex <= outsideCanon ? 2 : 3;
@@ -252,18 +246,18 @@ function generateSidebarForFlash(flash, { link, language, wikiData }) {
 
   return {
     content: fixWS`
-            <h1>${link.flashIndex("", {
-              text: language.$("flashIndex.title"),
+            <h1>${link.flashIndex('', {
+              text: language.$('flashIndex.title'),
             })}</h1>
             <dl>
                 ${flashActData
                   .filter(
                     (act) =>
-                      act.name.startsWith("Act 1") ||
-                      act.name.startsWith("Act 6 Act 1") ||
-                      act.name.startsWith("Hiveswap") ||
+                      act.name.startsWith('Act 1') ||
+                      act.name.startsWith('Act 6 Act 1') ||
+                      act.name.startsWith('Hiveswap') ||
                       // Sorry not sorry -Yiffy
-                      (({ index = flashActData.indexOf(act) } = {}) =>
+                      (({index = flashActData.indexOf(act)} = {}) =>
                         index < act6
                           ? side === 1
                           : index < outsideCanon
@@ -271,43 +265,43 @@ function generateSidebarForFlash(flash, { link, language, wikiData }) {
                           : true)()
                   )
                   .flatMap((act) => [
-                    (act.name.startsWith("Act 1") &&
+                    (act.name.startsWith('Act 1') &&
                       html.tag(
-                        "dt",
-                        { class: ["side", side === 1 && "current"] },
+                        'dt',
+                        {class: ['side', side === 1 && 'current']},
                         link.flash(act.flashes[0], {
-                          color: "#4ac925",
+                          color: '#4ac925',
                           text: `Side 1 (Acts 1-5)`,
                         })
                       )) ||
-                      (act.name.startsWith("Act 6 Act 1") &&
+                      (act.name.startsWith('Act 6 Act 1') &&
                         html.tag(
-                          "dt",
-                          { class: ["side", side === 2 && "current"] },
+                          'dt',
+                          {class: ['side', side === 2 && 'current']},
                           link.flash(act.flashes[0], {
-                            color: "#1076a2",
+                            color: '#1076a2',
                             text: `Side 2 (Acts 6-7)`,
                           })
                         )) ||
-                      (act.name.startsWith("Hiveswap Act 1") &&
+                      (act.name.startsWith('Hiveswap Act 1') &&
                         html.tag(
-                          "dt",
-                          { class: ["side", side === 3 && "current"] },
+                          'dt',
+                          {class: ['side', side === 3 && 'current']},
                           link.flash(act.flashes[0], {
-                            color: "#008282",
+                            color: '#008282',
                             text: `Outside Canon (Misc. Games)`,
                           })
                         )),
-                    (({ index = flashActData.indexOf(act) } = {}) =>
+                    (({index = flashActData.indexOf(act)} = {}) =>
                       index < act6
                         ? side === 1
                         : index < outsideCanon
                         ? side === 2
                         : true)() &&
                       html.tag(
-                        "dt",
-                        { class: act === currentAct && "current" },
-                        link.flash(act.flashes[0], { text: act.name })
+                        'dt',
+                        {class: act === currentAct && 'current'},
+                        link.flash(act.flashes[0], {text: act.name})
                       ),
                     act === currentAct &&
                       fixWS`
@@ -315,17 +309,17 @@ function generateSidebarForFlash(flash, { link, language, wikiData }) {
                             ${act.flashes
                               .map((f) =>
                                 html.tag(
-                                  "li",
-                                  { class: f === flash && "current" },
+                                  'li',
+                                  {class: f === flash && 'current'},
                                   link.flash(f)
                                 )
                               )
-                              .join("\n")}
+                              .join('\n')}
                         </ul></dd>
                     `,
                   ])
                   .filter(Boolean)
-                  .join("\n")}
+                  .join('\n')}
             </dl>
         `,
   };