From 4075254c9e38be6741527e1fb535eed444e6ad08 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Sun, 26 Jun 2022 16:41:09 -0300 Subject: initial prettier/eslint commit --- src/page/homepage.js | 269 +++++++++++++++++++++++++++++++-------------------- 1 file changed, 165 insertions(+), 104 deletions(-) (limited to 'src/page/homepage.js') diff --git a/src/page/homepage.js b/src/page/homepage.js index a19df6cf..ebe3a8d3 100644 --- a/src/page/homepage.js +++ b/src/page/homepage.js @@ -2,123 +2,184 @@ // 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 { - getNewAdditions, - getNewReleases -} from '../util/wiki-data.js'; +import { getNewAdditions, getNewReleases } from "../util/wiki-data.js"; // Page exports -export function writeTargetless({wikiData}) { - const { newsData, staticPageData, homepageLayout, wikiInfo } = wikiData; - - const page = { - type: 'page', - path: ['home'], - page: ({ - getAlbumGridHTML, - getLinkThemeString, - link, - language, - to, - transformInline, - transformMultiline - }) => ({ - title: wikiInfo.name, - showWikiNameInTitle: false, - - meta: { - description: wikiInfo.description - }, - - main: { - classes: ['top-index'], - content: fixWS` +export function writeTargetless({ wikiData }) { + const { newsData, staticPageData, homepageLayout, wikiInfo } = wikiData; + + const page = { + type: "page", + path: ["home"], + page: ({ + getAlbumGridHTML, + getLinkThemeString, + link, + language, + to, + transformInline, + transformMultiline, + }) => ({ + title: wikiInfo.name, + showWikiNameInTitle: false, + + meta: { + description: wikiInfo.description, + }, + + main: { + classes: ["top-index"], + content: fixWS`

${wikiInfo.name}

- ${homepageLayout.rows?.map((row, i) => fixWS` -
+ ${homepageLayout.rows + ?.map( + (row, i) => fixWS` +

${row.name}

- ${row.type === 'albums' && fixWS` + ${ + row.type === "albums" && + fixWS`
${getAlbumGridHTML({ - entries: ( - row.sourceGroupByRef === 'new-releases' ? getNewReleases(row.countAlbumsFromGroup, {wikiData}) : - row.sourceGroupByRef === 'new-additions' ? getNewAdditions(row.countAlbumsFromGroup, {wikiData}) : - ((row.sourceGroup?.albums ?? []) - .slice() - .reverse() - .filter(album => album.isListedOnHomepage) - .slice(0, row.countAlbumsFromGroup) - .map(album => ({item: album}))) - ).concat(row.sourceAlbums.map(album => ({item: album}))), - lazy: i > 0 + entries: (row.sourceGroupByRef === + "new-releases" + ? getNewReleases( + row.countAlbumsFromGroup, + { wikiData } + ) + : row.sourceGroupByRef === + "new-additions" + ? getNewAdditions( + row.countAlbumsFromGroup, + { wikiData } + ) + : (row.sourceGroup?.albums ?? []) + .slice() + .reverse() + .filter( + (album) => + album.isListedOnHomepage + ) + .slice(0, row.countAlbumsFromGroup) + .map((album) => ({ item: album })) + ).concat( + row.sourceAlbums.map((album) => ({ + item: album, + })) + ), + lazy: i > 0, })} - ${row.actionLinks?.length && fixWS` + ${ + row.actionLinks?.length && + fixWS`
- ${row.actionLinks.map(action => transformInline(action) - .replace(' + transformInline(action).replace( + " - `} + ` + }
- `} + ` + }
- `).join('\n')} - ` - }, - - sidebarLeft: homepageLayout.sidebarContent && { - wide: true, - collapse: false, - // This is a pretty filthy hack! 8ut otherwise, the [[news]] part - // gets treated like it's a reference to the track named "news", - // which o8viously isn't what we're going for. Gotta catch that - // 8efore we pass it to transformMultiline, 'cuz otherwise it'll - // get repl8ced with just the word "news" (or anything else that - // transformMultiline does with references it can't match) -- and - // we can't match that for replacing it with the news column! - // - // And no, I will not make [[news]] into part of transformMultiline - // (even though that would 8e hilarious). - content: (transformMultiline(homepageLayout.sidebarContent.replace('[[news]]', '__GENERATE_NEWS__')) - .replace('

__GENERATE_NEWS__

', wikiInfo.enableNews ? fixWS` -

${language.$('homepage.news.title')}

- ${newsData.slice(0, 3).map((entry, i) => html.tag('article', - {class: ['news-entry', i === 0 && 'first-news-entry']}, - fixWS` -

${link.newsEntry(entry)}

+ ` + ) + .join("\n")} + `, + }, + + sidebarLeft: homepageLayout.sidebarContent && { + wide: true, + collapse: false, + // This is a pretty filthy hack! 8ut otherwise, the [[news]] part + // gets treated like it's a reference to the track named "news", + // which o8viously isn't what we're going for. Gotta catch that + // 8efore we pass it to transformMultiline, 'cuz otherwise it'll + // get repl8ced with just the word "news" (or anything else that + // transformMultiline does with references it can't match) -- and + // we can't match that for replacing it with the news column! + // + // And no, I will not make [[news]] into part of transformMultiline + // (even though that would 8e hilarious). + content: transformMultiline( + homepageLayout.sidebarContent.replace("[[news]]", "__GENERATE_NEWS__") + ).replace( + "

__GENERATE_NEWS__

", + wikiInfo.enableNews + ? fixWS` +

${language.$("homepage.news.title")}

+ ${newsData + .slice(0, 3) + .map((entry, i) => + html.tag( + "article", + { + class: [ + "news-entry", + i === 0 && "first-news-entry", + ], + }, + fixWS` +

${link.newsEntry(entry)}

${transformMultiline(entry.contentShort)} - ${entry.contentShort !== entry.content && link.newsEntry(entry, { - text: language.$('homepage.news.entry.viewRest') - })} - `)).join('\n')} - ` : `

News requested in content description but this feature isn't enabled

`)) - }, - - nav: { - linkContainerClasses: ['nav-links-index'], - links: [ - link.home('', {text: wikiInfo.nameShort, class: 'current', to}), - - wikiInfo.enableListings && - link.listingIndex('', {text: language.$('listingIndex.title'), to}), - - wikiInfo.enableNews && - link.newsIndex('', {text: language.$('newsIndex.title'), to}), - - wikiInfo.enableFlashesAndGames && - link.flashIndex('', {text: language.$('flashIndex.title'), to}), - - ...(staticPageData - .filter(page => page.showInNavigationBar) - .map(page => link.staticPage(page, {text: page.nameShort}))), - ].filter(Boolean).map(html => ({html})), - } - }) - }; - - return [page]; + ${ + entry.contentShort !== entry.content && + link.newsEntry(entry, { + text: language.$( + "homepage.news.entry.viewRest" + ), + }) + } + ` + ) + ) + .join("\n")} + ` + : `

News requested in content description but this feature isn't enabled

` + ), + }, + + nav: { + linkContainerClasses: ["nav-links-index"], + links: [ + link.home("", { text: wikiInfo.nameShort, class: "current", to }), + + wikiInfo.enableListings && + link.listingIndex("", { + text: language.$("listingIndex.title"), + to, + }), + + wikiInfo.enableNews && + link.newsIndex("", { text: language.$("newsIndex.title"), to }), + + wikiInfo.enableFlashesAndGames && + link.flashIndex("", { text: language.$("flashIndex.title"), to }), + + ...staticPageData + .filter((page) => page.showInNavigationBar) + .map((page) => link.staticPage(page, { text: page.nameShort })), + ] + .filter(Boolean) + .map((html) => ({ html })), + }, + }), + }; + + return [page]; } -- cgit 1.3.0-6-gf8a5