diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2023-07-02 15:52:57 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2023-07-02 15:52:57 -0300 |
commit | 83325d6034a1f7ee1d861b8179c0edb9a7e0537d (patch) | |
tree | 955a016c78df87ad7e7b8c4a13ae785a3c9b15aa /src/content | |
parent | 1d670edff0cdb6ff696cedac08ecbdf39aa7c085 (diff) |
generateAlbumTrackList: don't hard-code content heading html
Diffstat (limited to 'src/content')
-rw-r--r-- | src/content/dependencies/generateAlbumTrackList.js | 37 |
1 files changed, 21 insertions, 16 deletions
diff --git a/src/content/dependencies/generateAlbumTrackList.js b/src/content/dependencies/generateAlbumTrackList.js index 1c0d37b3..b222799b 100644 --- a/src/content/dependencies/generateAlbumTrackList.js +++ b/src/content/dependencies/generateAlbumTrackList.js @@ -35,10 +35,7 @@ function getDisplayMode(album) { } export default { - contentDependencies: [ - 'generateAlbumTrackListItem', - ], - + contentDependencies: ['generateAlbumTrackListItem', 'generateContentHeading'], extraDependencies: ['html', 'language'], query(album) { @@ -52,10 +49,15 @@ export default { switch (query.displayMode) { case 'trackSections': + relations.trackSectionHeadings = + album.trackSections.map(() => + relation('generateContentHeading')); + relations.itemsByTrackSection = album.trackSections.map(section => section.tracks.map(track => relation('generateAlbumTrackListItem', track, album))); + break; case 'tracks': @@ -103,23 +105,26 @@ export default { case 'trackSections': return html.tag('dl', {class: 'album-group-list'}, stitchArrays({ + heading: relations.trackSectionHeadings, + items: relations.itemsByTrackSection, info: data.trackSectionInfo, - item: relations.itemsByTrackSection, - }).map(({info, item}) => [ - html.tag('dt', - {class: 'content-heading', tabindex: '0'}, - language.$('trackList.section.withDuration', { - section: info.name, - duration: - language.formatDuration(info.duration, { - approximate: info.durationApproximate, - }), - })), + }).map(({heading, items, info}) => [ + heading.slots({ + tag: 'dt', + title: + language.$('trackList.section.withDuration', { + section: info.name, + duration: + language.formatDuration(info.duration, { + approximate: info.durationApproximate, + }), + }), + }), html.tag('dd', html.tag(listTag, data.hasTrackNumbers ? {start: info.startIndex + 1} : {}, - item)), + items)), ])); case 'tracks': |