From 2ccb0588a304b3ce8855651e8a30f895a57880c0 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Tue, 7 Jul 2026 21:18:03 -0300 Subject: data, content, css: Aside Traack Section, Close Aside Track Section --- src/data/files/album.js | 38 ++++++++++++++++++++++++++++++++++- src/data/things/album/TrackSection.js | 14 +++++++++++++ src/data/things/album/index.js | 3 +++ 3 files changed, 54 insertions(+), 1 deletion(-) (limited to 'src/data') 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; } diff --git a/src/data/things/album/TrackSection.js b/src/data/things/album/TrackSection.js index e579a0f6..86c754ac 100644 --- a/src/data/things/album/TrackSection.js +++ b/src/data/things/album/TrackSection.js @@ -50,6 +50,12 @@ export class TrackSection extends Thing { name: name(V('Unnamed Track Section')), + style: { + flags: {update: true, expose: true}, + update: {validate: is('section', 'aside')}, + expose: {transform: value => value ?? 'section'}, + }, + // Track sections don't have a Name Detail themselves, but they do provide // a value which tracks can reference via 'Name Detail: section'. nameDetailForTracks: { @@ -147,6 +153,14 @@ export class TrackSection extends Thing { validate: input.value(isBoolean), }), + { + dependencies: ['style'], + compute: (continuation, {style}) => + (style === 'aside' + ? true + : continuation()), + }, + withPropertyFromObject('album', V('hideTrackSectionDurations')), exposeDependency('#album.hideTrackSectionDurations'), ], diff --git a/src/data/things/album/index.js b/src/data/things/album/index.js index 67bf47ab..a19144d9 100644 --- a/src/data/things/album/index.js +++ b/src/data/things/album/index.js @@ -1,2 +1,5 @@ export * from './Album.js'; export * from './TrackSection.js'; + +export * from './AsideTrackSection.js'; +export * from './CloseAsideTrackSection.js'; -- cgit 1.3.0-6-gf8a5