diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2023-05-02 13:56:24 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2023-05-02 13:56:24 -0300 |
commit | bf6bff764880f96597f915bd9a59abfaaf310db1 (patch) | |
tree | 644a7cacb30aed48d49dfc44f7a91ecb14339c28 | |
parent | 04a617eb5fbe7023c7af91f843b9f482f0c604ea (diff) |
content: generateAlbumSidebar: clean up content logic
-rw-r--r-- | src/content/dependencies/generateAlbumSidebar.js | 67 |
1 files 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, + ], + }; }, }; |