« get me outta code hell

generateArtistInfoPageOtherArtistLinks.js « dependencies « content « src - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/content/dependencies/generateArtistInfoPageOtherArtistLinks.js
blob: dea7742a30fe5c2c4960710de7d6450ef7b48c51 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import {empty} from '#sugar';

export default {
  contentDependencies: ['linkArtist'],

  relations(relation, contribs, artist) {
    const otherArtistContribs = contribs.filter(({who}) => who !== artist);

    if (empty(otherArtistContribs)) {
      return {};
    }

    const otherArtistLinks =
      otherArtistContribs
        .map(({who}) => relation('linkArtist', who));

    return {otherArtistLinks};
  },

  generate(relations) {
    return relations.otherArtistLinks ?? null;
  },
};