From bf0d82c405396471c0b606a7c4401b2109967ee6 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Sat, 2 Nov 2024 23:07:55 -0300 Subject: content: generateAlbumSecondaryNav: group-disconnected series --- .../dependencies/generateAlbumSecondaryNav.js | 32 +++++++++++++++++++--- 1 file changed, 28 insertions(+), 4 deletions(-) (limited to 'src/content/dependencies/generateAlbumSecondaryNav.js') diff --git a/src/content/dependencies/generateAlbumSecondaryNav.js b/src/content/dependencies/generateAlbumSecondaryNav.js index ed43e51f..5a5ebbda 100644 --- a/src/content/dependencies/generateAlbumSecondaryNav.js +++ b/src/content/dependencies/generateAlbumSecondaryNav.js @@ -8,9 +8,15 @@ export default { 'generateSecondaryNav', ], - extraDependencies: ['html'], + extraDependencies: ['html', 'wikiData'], - query(album) { + sprawl: ({groupData}) => ({ + // TODO: Series aren't their own things, so we access them weirdly. + seriesData: + groupData.flatMap(group => group.serieses), + }), + + query(sprawl, album) { const query = {}; query.groups = @@ -22,10 +28,16 @@ export default { group.serieses .filter(series => series.albums.includes(album))); + query.disconnectedSerieses = + sprawl.seriesData + .filter(series => + series.albums.includes(album) && + !query.groups.includes(series.group)); + return query; }, - relations: (relation, query, album) => ({ + relations: (relation, query, _sprawl, album) => ({ secondaryNav: relation('generateSecondaryNav'), @@ -49,6 +61,13 @@ export default { relation('generateAlbumSecondaryNavSeriesPart', series, album))), + + disconnectedSeriesParts: + query.disconnectedSerieses + .map(series => + relation('generateAlbumSecondaryNavSeriesPart', + series, + album)), }), slots: { @@ -59,7 +78,7 @@ export default { }, generate(relations, slots, {html}) { - const allParts = + const groupConnectedParts = stitchArrays({ groupPart: relations.groupParts, seriesParts: relations.seriesParts, @@ -77,6 +96,11 @@ export default { } }); + const allParts = [ + ...relations.disconnectedSeriesParts, + ...groupConnectedParts, + ]; + return relations.secondaryNav.slots({ class: [ 'album-secondary-nav', -- cgit 1.3.0-6-gf8a5