« get me outta code hell

generateMusicVideoArtistsLine.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/generateMusicVideoArtistsLine.js
blob: 959d36486b000548f1abe616a2474e4e2dd248e9 (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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
export default {
  relations: (relation, musicVideo) => ({
    artistCredit:
      relation('generateArtistCredit', musicVideo.artistContribs, []),
  }),

  data: (musicVideo) => ({
    label:
      (musicVideo.label !== 'Music video'
        ? musicVideo.label
        : null),
  }),

  generate(data, relations, {html, language}) {
    const {artistCredit} = relations;
    const capsule = language.encapsulate('misc.musicVideo');

    let artistsLineCapsule = language.encapsulate(capsule, 'artistsLine');
    let artistsLineOptions = {[language.onlyIfOptions]: ['credit']};

    if (data.label) {
      artistsLineCapsule += '.customLabel';
      artistsLineOptions.label = data.label;
    }

    artistsLineOptions.credit =
      html.tag('span', {class: 'by'},
        {[html.onlyIfContent]: true},

        artistCredit.slots({
          normalStringKey: language.encapsulate(capsule, 'artistsLine.credit'),

          showAnnotation: true,
          showChronology: true,

          chronologyKind: 'musicVideo',
        }));

    return language.$(artistsLineCapsule, artistsLineOptions);
  },
}