From 8a36571fdef4fd7b815640439d736fb4bd822ec4 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Fri, 24 Oct 2025 06:59:30 -0300 Subject: 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. --- src/data/yaml.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/data/yaml.js') 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 = { -- cgit 1.3.0-6-gf8a5