« 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: 7667dea7c1868d47e899066bcbe2e119cb410894 (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 '../../util/sugar.js';

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;
  },
};