« 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: 471ee26c0ba193bd42a9467cdc0c5a5ce3a214b3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import {empty} from '#sugar';

export default {
  contentDependencies: ['linkArtist'],

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

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

    const otherArtistLinks =
      otherArtistContribs
        .map(contrib => relation('linkArtist', contrib.artist));

    return {otherArtistLinks};
  },

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