From cde9bdcdd35ecf9246552af192876a84d21f60ea Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Sat, 11 Jan 2025 17:35:02 -0400 Subject: reverse: artworksWhichReference --- src/reverse.js | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/reverse.js b/src/reverse.js index 9b642e39..22746d24 100644 --- a/src/reverse.js +++ b/src/reverse.js @@ -74,7 +74,28 @@ function reverseHelper(spec) { }; } -const hardcodedReverseSpecs = {}; +const hardcodedReverseSpecs = { + // Artworks aren't Thing objects. + // This spec operates on albums and tracks alike! + artworksWhichReference: { + bindTo: 'wikiData', + + referencing: ({albumData, trackData}) => + [...albumData, ...trackData] + .flatMap(referencingThing => + referencingThing.referencedArtworks + .map(({thing: referencedThing, ...referenceDetails}) => ({ + referencingThing, + referencedThing, + referenceDetails, + }))), + + referenced: ({referencedThing}) => [referencedThing], + + tidy: ({referencingThing, referenceDetails}) => + ({thing: referencingThing, ...referenceDetails}), + }, +}; const findReverseHelperConfig = { word: `reverse`, -- cgit 1.3.0-6-gf8a5