From 1cd87253681074907db8e6751fd787e37b7d17b5 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Tue, 11 Feb 2025 10:20:51 -0400 Subject: data: linkWikiDataArrays: use getNestedProp --- src/data/yaml.js | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) (limited to 'src/data/yaml.js') diff --git a/src/data/yaml.js b/src/data/yaml.js index a1eb73fb..fbe5b7d4 100644 --- a/src/data/yaml.js +++ b/src/data/yaml.js @@ -30,6 +30,7 @@ import { atOffset, empty, filterProperties, + getNestedProp, stitchArrays, typeAppearance, withEntries, @@ -1230,39 +1231,39 @@ export function linkWikiDataArrays(wikiData, {bindFind, bindReverse}) { // entries must be present here even without any properties to explicitly // link if the 'find' or 'reverse' properties will be implicitly linked - [wikiData.albumData, [ + ['albumData', [ 'albumData', 'trackData', 'wikiInfo', ]], - [wikiData.artTagData, [/* reverse */]], + ['artTagData', [/* reverse */]], - [wikiData.artistData, [/* find, reverse */]], + ['artistData', [/* find, reverse */]], - [wikiData.flashData, [ + ['flashData', [ 'wikiInfo', ]], - [wikiData.flashActData, [/* find, reverse */]], + ['flashActData', [/* find, reverse */]], - [wikiData.flashSideData, [/* find */]], + ['flashSideData', [/* find */]], - [wikiData.groupData, [/* find, reverse */]], + ['groupData', [/* find, reverse */]], - [wikiData.groupCategoryData, [/* find */]], + ['groupCategoryData', [/* find */]], - [wikiData.homepageLayout.rows, [/* find */]], + ['homepageLayout.rows', [/* find */]], - [wikiData.trackData, [ + ['trackData', [ 'albumData', 'trackData', 'wikiInfo', ]], - [wikiData.trackSectionData, [/* reverse */]], + ['trackSectionData', [/* reverse */]], - [[wikiData.wikiInfo], [/* find */]], + ['wikiInfo', [/* find */]], ]); const constructorHasFindMap = new Map(); @@ -1271,8 +1272,12 @@ export function linkWikiDataArrays(wikiData, {bindFind, bindReverse}) { const boundFind = bindFind(wikiData); const boundReverse = bindReverse(wikiData); - for (const [things, keys] of linkWikiDataSpec.entries()) { - if (things === undefined) continue; + for (const [thingDataProp, keys] of linkWikiDataSpec.entries()) { + const thingData = getNestedProp(wikiData, thingDataProp); + const things = + (Array.isArray(thingData) + ? thingData.flat(Infinity) + : [thingData]); for (const thing of things) { if (thing === undefined) continue; -- cgit 1.3.0-6-gf8a5