diff options
| author | (quasar) nebula <qznebula@protonmail.com> | 2025-10-24 06:59:30 -0300 |
|---|---|---|
| committer | (quasar) nebula <qznebula@protonmail.com> | 2025-10-24 07:01:02 -0300 |
| commit | 8a36571fdef4fd7b815640439d736fb4bd822ec4 (patch) | |
| tree | 24b011629a124c78aa024b9ebb3d5880e8b42377 /src/data/yaml.js | |
| parent | 2b7c3305d916875e98d33102d50ab562834b1e0a (diff) | |
data: use subdocs for artist aliases
They're still exposed as Artist instances. This commit only changes how those instances come to be, and are bound with the main artist.
Diffstat (limited to 'src/data/yaml.js')
| -rw-r--r-- | src/data/yaml.js | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/data/yaml.js b/src/data/yaml.js index 46cb4eda..13dfd24d 100644 --- a/src/data/yaml.js +++ b/src/data/yaml.js @@ -982,6 +982,30 @@ export function parseLyrics(value, {subdoc, LyricsEntry}) { return parseContentEntries(LyricsEntry, value, {subdoc}); } +export function parseArtistAliases(value, {subdoc, Artist}) { + return parseArrayEntries(value, item => { + const config = { + bindInto: 'aliasedArtist', + provide: {isAlias: true}, + }; + + if (typeof item === 'string') { + return subdoc(Artist, {'Artist': item}, config); + } else if (typeof item === 'object' && !Array.isArray(item)) { + if (item['Name']) { + const clone = {...item}; + clone['Artist'] = item['Name']; + delete clone['Name']; + return subdoc(Artist, clone, config); + } else { + return subdoc(Artist, item, config); + } + } else { + return item; + } + }); +} + // documentModes: Symbols indicating sets of behavior for loading and processing // data files. export const documentModes = { |