diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2024-11-02 23:08:18 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2024-11-02 23:08:18 -0300 |
commit | 4ce3e7afbc99cc4a6efe9b63a4b53cde6384cde7 (patch) | |
tree | 8d4ddf24e723acaeb5fde6cea068cd6cc216fb94 /src/content/dependencies | |
parent | bf0d82c405396471c0b606a7c4401b2109967ee6 (diff) |
content: generateAlbumSidebar: group-disconnected series
Diffstat (limited to 'src/content/dependencies')
-rw-r--r-- | src/content/dependencies/generateAlbumSidebar.js | 47 |
1 files changed, 36 insertions, 11 deletions
diff --git a/src/content/dependencies/generateAlbumSidebar.js b/src/content/dependencies/generateAlbumSidebar.js index 3557a178..bd53ef71 100644 --- a/src/content/dependencies/generateAlbumSidebar.js +++ b/src/content/dependencies/generateAlbumSidebar.js @@ -9,9 +9,15 @@ export default { 'generatePageSidebarConjoinedBox', ], - 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 = @@ -23,10 +29,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, track) => ({ + relations: (relation, query, _sprawl, album, track) => ({ sidebar: relation('generatePageSidebar'), @@ -46,9 +58,14 @@ export default { .map(serieses => serieses .map(series => relation('generateAlbumSidebarSeriesBox', album, series))), + + disconnectedSeriesBoxes: + query.disconnectedSerieses + .map(series => + relation('generateAlbumSidebarSeriesBox', album, series)), }), - data: (_query, _album, track) => ({ + data: (_query, _sprawl, _album, track) => ({ isAlbumPage: !track, }), @@ -56,6 +73,7 @@ export default { for (const box of [ ...relations.groupBoxes, ...relations.seriesBoxes.flat(), + ...relations.disconnectedSeriesBoxes, ]) { box.setSlot('mode', data.isAlbumPage ? 'album' : 'track'); @@ -63,7 +81,9 @@ export default { return relations.sidebar.slots({ boxes: [ - data.isAlbumPage && + data.isAlbumPage && [ + relations.disconnectedSeriesBoxes, + stitchArrays({ groupBox: relations.groupBoxes, seriesBoxes: relations.seriesBoxes, @@ -76,6 +96,7 @@ export default { seriesBox, ]), ]), + ], relations.trackListBox, @@ -83,14 +104,18 @@ export default { relations.conjoinedBox.slots({ attributes: {class: 'conjoined-group-sidebar-box'}, boxes: - stitchArrays({ - groupBox: relations.groupBoxes, - seriesBoxes: relations.seriesBoxes, - }).map(({groupBox, seriesBoxes}) => [groupBox, ...seriesBoxes]) - .flat() + ([relations.disconnectedSeriesBoxes, + stitchArrays({ + groupBox: relations.groupBoxes, + seriesBoxes: relations.seriesBoxes, + }).flatMap(({groupBox, seriesBoxes}) => [ + groupBox, + ...seriesBoxes, + ]), + ]).flat() .map(box => box.content), /* TODO: Kludge. */ }), ], }); - } + }, }; |