diff options
| author | (quasar) nebula <qznebula@protonmail.com> | 2026-07-07 21:18:03 -0300 |
|---|---|---|
| committer | (quasar) nebula <qznebula@protonmail.com> | 2026-07-07 21:18:03 -0300 |
| commit | 2ccb0588a304b3ce8855651e8a30f895a57880c0 (patch) | |
| tree | f878792b2c8dbb632f9acbd7ac1ed85aed25923d /src/data/files/album.js | |
| parent | b15da97e76176344d8b977558940a7f4324c0876 (diff) | |
data, content, css: Aside Traack Section, Close Aside Track Section preview
Diffstat (limited to 'src/data/files/album.js')
| -rw-r--r-- | src/data/files/album.js | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/src/data/files/album.js b/src/data/files/album.js index 84cda226..da687ddf 100644 --- a/src/data/files/album.js +++ b/src/data/files/album.js @@ -3,10 +3,18 @@ import * as path from 'node:path'; import {traverse} from '#node-utils'; import {sortAlbumsTracksChronologically, sortChronologically} from '#sort'; import {empty} from '#sugar'; +import Thing from '#thing'; export default ({ documentModes: {headerAndEntries}, - thingConstructors: {Album, Track, TrackSection}, + thingConstructors: { + Album, + Track, + TrackSection, + + AsideTrackSection, + CloseAsideTrackSection, + }, }) => ({ title: `Process album files`, @@ -21,6 +29,10 @@ export default ({ entryDocumentThing: document => ('Section' in document ? TrackSection + : 'Aside Section' in document + ? AsideTrackSection + : 'Close Aside Section' in document + ? CloseAsideTrackSection : Track), connect({header: album, entries}) { @@ -29,6 +41,8 @@ export default ({ let currentTrackSection = new TrackSection(); let currentTrackSectionTracks = []; + let latestNonAsideTrackSection = currentTrackSection; + Object.assign(currentTrackSection, { name: `Default Track Section`, isDefaultTrackSection: true, @@ -53,6 +67,28 @@ export default ({ closeCurrentTrackSection(); currentTrackSection = entry; currentTrackSectionTracks = []; + + if (entry.style !== 'aside') { + latestNonAsideTrackSection = entry; + } + + continue; + } + + if (entry instanceof CloseAsideTrackSection) { + if (currentTrackSection.style !== 'aside') { + throw new Error(`Current track section "${currentTrackSection.name}" is not an aside`); + } + + if (entry.name !== currentTrackSection.name) { + throw new Error(`Expected "Close Aside Section: ${currentTrackSection.name}", got "${entry.name}"`); + } + + closeCurrentTrackSection(); + currentTrackSection = Thing.clone(latestNonAsideTrackSection); + currentTrackSection.tracks = []; + currentTrackSectionTracks = []; + continue; } |