From f34a6baadda3ba87cc482aee34ecb256879730c5 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Wed, 5 Feb 2025 16:08:05 -0400 Subject: page: use path conditions --- src/page/group.js | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) (limited to 'src/page/group.js') diff --git a/src/page/group.js b/src/page/group.js index b0ed5baf..87590eaf 100644 --- a/src/page/group.js +++ b/src/page/group.js @@ -7,8 +7,6 @@ export function targets({wikiData}) { } export function pathsForTarget(group) { - const hasGalleryPage = !empty(group.albums); - return [ { type: 'page', @@ -20,10 +18,13 @@ export function pathsForTarget(group) { }, }, - hasGalleryPage && { + { type: 'page', path: ['groupGallery', group.directory], + condition: () => + !empty(group.albums), + contentFunction: { name: 'generateGroupGalleryPage', args: [group], @@ -34,20 +35,24 @@ export function pathsForTarget(group) { export function pathsTargetless({wikiData: {wikiInfo}}) { return [ - wikiInfo.canonicalBase === 'https://hsmusic.wiki/' && - { - type: 'redirect', - fromPath: ['page', 'albums/fandom'], - toPath: ['groupGallery', 'fandom'], - title: 'Fandom - Gallery', - }, + { + type: 'redirect', + fromPath: ['page', 'albums/fandom'], + toPath: ['groupGallery', 'fandom'], + title: 'Fandom - Gallery', - wikiInfo.canonicalBase === 'https://hsmusic.wiki/' && - { - type: 'redirect', - fromPath: ['page', 'albums/official'], - toPath: ['groupGallery', 'official'], - title: 'Official - Gallery', - }, + condition: () => + wikiInfo.canonicalBase === 'https://hsmusic.wiki/', + }, + + { + type: 'redirect', + fromPath: ['page', 'albums/official'], + toPath: ['groupGallery', 'official'], + title: 'Official - Gallery', + + condition: () => + wikiInfo.canonicalBase === 'https://hsmusic.wiki/', + }, ]; } -- cgit 1.3.0-6-gf8a5