From 8f39a21ef27f8b66cd49c01e38937d133f13859d Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Tue, 8 Aug 2023 11:03:25 -0300 Subject: content: move hard-coded redirects into page files --- src/page/album.js | 11 +++++++++++ src/page/group.js | 18 ++++++++++++++++++ src/write/build-modes/static-build.js | 32 -------------------------------- 3 files changed, 29 insertions(+), 32 deletions(-) diff --git a/src/page/album.js b/src/page/album.js index a8e0b591..1d5c7c0f 100644 --- a/src/page/album.js +++ b/src/page/album.js @@ -55,6 +55,17 @@ export function pathsForTarget(album) { ]; } +export function pathsTargetless({wikiData: {wikiInfo}}) { + return [ + wikiInfo.canonicalBase === 'https://hsmusic.wiki/' && + { + type: 'redirect', + fromPath: ['path', 'list/all-commentary/'], + toPath: ['commentaryIndex'], + }, + ]; +} + /* export function write(album, {wikiData}) { const getSocialEmbedDescription = ({ diff --git a/src/page/group.js b/src/page/group.js index 4d5f91c8..8795e15b 100644 --- a/src/page/group.js +++ b/src/page/group.js @@ -40,3 +40,21 @@ export function pathsForTarget(group) { }, ]; } + +export function pathsTargetless({wikiData: {wikiInfo}}) { + return [ + wikiInfo.canonicalBase === 'https://hsmusic.wiki/' && + { + type: 'redirect', + fromPath: ['path', 'albums/fandom/'], + toPath: ['groupGallery', 'fandom'], + }, + + wikiInfo.canonicalBase === 'https://hsmusic.wiki/' && + { + type: 'redirect', + fromPath: ['path', 'albums/official/'], + toPath: ['groupGallery', 'official'], + }, + ]; +} diff --git a/src/write/build-modes/static-build.js b/src/write/build-modes/static-build.js index 60614c29..dc2bb2c0 100644 --- a/src/write/build-modes/static-build.js +++ b/src/write/build-modes/static-build.js @@ -503,41 +503,9 @@ async function writeSharedFilesAndPages({ const {groupData, wikiInfo} = wikiData; return progressPromiseAll(`Writing files & pages shared across languages.`, [ - groupData?.some((group) => group.directory === 'fandom') && - redirect({ - title: 'Fandom - Gallery', - from: 'albums/fandom', - to: ['localized.groupGallery', 'fandom'], - }), - - groupData?.some((group) => group.directory === 'official') && - redirect({ - title: 'Official - Gallery', - from: 'albums/official', - to: ['localized.groupGallery', 'official'], - }), - - wikiInfo.enableListings && - redirect({ - title: 'Album Commentary', - from: 'list/all-commentary', - to: ['localized.commentaryIndex'], - }), - wikiDataJSON && writeFile( path.join(outputPath, 'data.json'), wikiDataJSON), ].filter(Boolean)); - - async function redirect({title, from, to: toPath}) { - const target = - path.relative( - from, - urls.from('shared.root').to(...toPath)); - - const content = generateRedirectHTML(title, target, {language}); - await mkdir(path.join(outputPath, from), {recursive: true}); - await writeFile(path.join(outputPath, from, 'index.html'), content); - } } -- cgit 1.3.0-6-gf8a5