diff options
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 |
commit | c75b029160248b6935e5c0f5156cc7a870311e82 (patch) | |
tree | 693c5cca195e50b048b0086e768aa06a7c1986ee /src/page/album-commentary.js | |
parent | f65e712fe8b8b1a196da2db286ebc6a5c9bf7433 (diff) |
real pragma, and some eslint fixes
Diffstat (limited to 'src/page/album-commentary.js')
-rw-r--r-- | src/page/album-commentary.js | 87 |
1 files changed, 42 insertions, 45 deletions
diff --git a/src/page/album-commentary.js b/src/page/album-commentary.js index b469838d..719bd65a 100644 --- a/src/page/album-commentary.js +++ b/src/page/album-commentary.js @@ -1,34 +1,34 @@ -// @format -// +/** @format */ + // Album commentary page and index specifications. // Imports -import fixWS from "fix-whitespace"; +import fixWS from 'fix-whitespace'; -import { filterAlbumsByCommentary } from "../util/wiki-data.js"; +import {filterAlbumsByCommentary} from '../util/wiki-data.js'; // Page exports -export function condition({ wikiData }) { +export function condition({wikiData}) { return filterAlbumsByCommentary(wikiData.albumData).length; } -export function targets({ wikiData }) { +export function targets({wikiData}) { return filterAlbumsByCommentary(wikiData.albumData); } -export function write(album, { wikiData }) { - const { wikiInfo } = wikiData; +export function write(album, {wikiData}) { + const {wikiInfo} = wikiData; const entries = [album, ...album.tracks] .filter((x) => x.commentary) .map((x) => x.commentary); - const words = entries.join(" ").split(" ").length; + const words = entries.join(' ').split(' ').length; const page = { - type: "page", - path: ["albumCommentary", album.directory], + type: 'page', + path: ['albumCommentary', album.directory], page: ({ getAlbumStylesheet, getLinkThemeString, @@ -38,30 +38,30 @@ export function write(album, { wikiData }) { to, transformMultiline, }) => ({ - title: language.$("albumCommentaryPage.title", { album: album.name }), + title: language.$('albumCommentaryPage.title', {album: album.name}), stylesheet: getAlbumStylesheet(album), theme: getThemeString(album.color), main: { content: fixWS` <div class="long-content"> - <h1>${language.$("albumCommentaryPage.title", { + <h1>${language.$('albumCommentaryPage.title', { album: link.album(album), })}</h1> - <p>${language.$("albumCommentaryPage.infoLine", { + <p>${language.$('albumCommentaryPage.infoLine', { words: `<b>${language.formatWordCount(words, { unit: true, })}</b>`, entries: `<b>${language.countCommentaryEntries( entries.length, - { unit: true } + {unit: true} )}</b>`, })}</p> ${ album.commentary && fixWS` <h3>${language.$( - "albumCommentaryPage.entry.title.albumCommentary" + 'albumCommentaryPage.entry.title.albumCommentary' )}</h3> <blockquote> ${transformMultiline(album.commentary)} @@ -73,7 +73,7 @@ export function write(album, { wikiData }) { .map( (track) => fixWS` <h3 id="${track.directory}">${language.$( - "albumCommentaryPage.entry.title.trackCommentary", + 'albumCommentaryPage.entry.title.trackCommentary', { track: link.track(track), } @@ -85,22 +85,22 @@ export function write(album, { wikiData }) { </blockquote> ` ) - .join("\n")} + .join('\n')} </div> `, }, nav: { - linkContainerClasses: ["nav-links-hierarchy"], + linkContainerClasses: ['nav-links-hierarchy'], links: [ - { toHome: true }, + {toHome: true}, { - path: ["localized.commentaryIndex"], - title: language.$("commentaryIndex.title"), + path: ['localized.commentaryIndex'], + title: language.$('commentaryIndex.title'), }, { - html: language.$("albumCommentaryPage.nav.album", { - album: link.albumCommentary(album, { class: "current" }), + html: language.$('albumCommentaryPage.nav.album', { + album: link.albumCommentary(album, {class: 'current'}), }), }, ], @@ -111,7 +111,7 @@ export function write(album, { wikiData }) { return [page]; } -export function writeTargetless({ wikiData }) { +export function writeTargetless({wikiData}) { const data = filterAlbumsByCommentary(wikiData.albumData) .map((album) => ({ album, @@ -119,44 +119,41 @@ export function writeTargetless({ wikiData }) { .filter((x) => x.commentary) .map((x) => x.commentary), })) - .map(({ album, entries }) => ({ + .map(({album, entries}) => ({ album, entries, - words: entries.join(" ").split(" ").length, + words: entries.join(' ').split(' ').length, })); - const totalEntries = data.reduce( - (acc, { entries }) => acc + entries.length, - 0 - ); - const totalWords = data.reduce((acc, { words }) => acc + words, 0); + const totalEntries = data.reduce((acc, {entries}) => acc + entries.length, 0); + const totalWords = data.reduce((acc, {words}) => acc + words, 0); const page = { - type: "page", - path: ["commentaryIndex"], - page: ({ link, language }) => ({ - title: language.$("commentaryIndex.title"), + type: 'page', + path: ['commentaryIndex'], + page: ({link, language}) => ({ + title: language.$('commentaryIndex.title'), main: { content: fixWS` <div class="long-content"> - <h1>${language.$("commentaryIndex.title")}</h1> - <p>${language.$("commentaryIndex.infoLine", { + <h1>${language.$('commentaryIndex.title')}</h1> + <p>${language.$('commentaryIndex.infoLine', { words: `<b>${language.formatWordCount(totalWords, { unit: true, })}</b>`, entries: `<b>${language.countCommentaryEntries( totalEntries, - { unit: true } + {unit: true} )}</b>`, })}</p> - <p>${language.$("commentaryIndex.albumList.title")}</p> + <p>${language.$('commentaryIndex.albumList.title')}</p> <ul> ${data .map( - ({ album, entries, words }) => fixWS` + ({album, entries, words}) => fixWS` <li>${language.$( - "commentaryIndex.albumList.item", + 'commentaryIndex.albumList.item', { album: link.albumCommentary(album), words: language.formatWordCount(words, { @@ -165,19 +162,19 @@ export function writeTargetless({ wikiData }) { entries: language.countCommentaryEntries( entries.length, - { unit: true } + {unit: true} ), } )}</li> ` ) - .join("\n")} + .join('\n')} </ul> </div> `, }, - nav: { simple: true }, + nav: {simple: true}, }), }; |