From bf6bff764880f96597f915bd9a59abfaaf310db1 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Tue, 2 May 2023 13:56:24 -0300 Subject: content: generateAlbumSidebar: clean up content logic --- src/content/dependencies/generateAlbumSidebar.js | 67 +++++++++++++----------- 1 file changed, 35 insertions(+), 32 deletions(-) diff --git a/src/content/dependencies/generateAlbumSidebar.js b/src/content/dependencies/generateAlbumSidebar.js index ab659b99..bf6b091a 100644 --- a/src/content/dependencies/generateAlbumSidebar.js +++ b/src/content/dependencies/generateAlbumSidebar.js @@ -30,44 +30,47 @@ export default { }, generate(data, relations, {html}) { - const {isAlbumPage} = data; + const trackListBox = { + content: + html.tags([ + html.tag('h1', relations.albumLink), + relations.trackSections, + ]), + }; - const trackListPart = html.tags([ - html.tag('h1', relations.albumLink), - relations.trackSections, - ]); + if (data.isAlbumPage) { + const groupBoxes = + relations.groupBoxes + .map(content => content.slot('isAlbumPage', true)) + .map(content => ({content})); - if (isAlbumPage) { return { - // leftSidebarStickyMode: 'last', leftSidebarMultiple: [ - ...( - relations.groupBoxes - .map(groupBox => groupBox.slot('isAlbumPage', true)) - .map(content => ({content}))), - {content: trackListPart}, - ], - }; - } else { - return { - // leftSidebarStickyMode: 'column', - leftSidebarMultiple: [ - {content: trackListPart}, - // ...relations.groupBoxes.map(content => ({content})), - { - content: - relations.groupBoxes - .flatMap((content, i, {length}) => [ - content, - i < length - 1 && - html.tag('hr', { - style: `border-color: var(--primary-color); border-style: none none dotted none` - }), - ]) - .filter(Boolean), - }, + ...groupBoxes, + trackListBox, ], }; } + + const conjoinedGroupBox = { + content: + relations.groupBoxes + .flatMap((content, i, {length}) => [ + content, + i < length - 1 && + html.tag('hr', { + style: `border-color: var(--primary-color); border-style: none none dotted none` + }), + ]) + .filter(Boolean), + }; + + return { + // leftSidebarStickyMode: 'column', + leftSidebarMultiple: [ + trackListBox, + conjoinedGroupBox, + ], + }; }, }; -- cgit 1.3.0-6-gf8a5