« get me outta code hell

generateArtistInfoPageMusicVideosChunk.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/generateArtistInfoPageMusicVideosChunk.js
blob: 6912d4d60323e9f7d23ca7c048177e72d5cfbd20 (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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
export default {
  relations: (relation, artist, album, contribs) => ({
    template:
      relation('generateArtistInfoPageChunk'),

    albumLink:
      relation('linkAlbum', album),

    albumArtistCredit:
      relation('generateArtistCredit', album.artistContribs, []),

    items:
      contribs.map(contribs =>
        relation('generateArtistInfoPageMusicVideosChunkItem',
          artist,
          contribs)),
  }),

  data: (_artist, album, contribs) => ({
    albumDate:
      album.date,

    contribDates:
      contribs
        .flat()
        .map(contrib => contrib.date),
  }),

  generate: (data, relations, {html, language}) =>
    relations.template.slots({
      mode: 'album',

      link:
        language.encapsulate('artistPage.creditList.album', workingCapsule => {
          const creditCapsule = workingCapsule + '.credit';
          const workingOptions = {album: relations.albumLink};

          relations.albumArtistCredit.setSlots({
            normalStringKey: creditCapsule + '.by',
          });

          if (!html.isBlank(relations.albumArtistCredit)) {
            workingCapsule += '.withCredit';
            workingOptions.credit =
              html.tag('span', {class: 'by'},
                relations.albumArtistCredit);
          }

          return language.$(workingCapsule, workingOptions);
        }),

      date: data.albumDate,
      dates: data.contribDates,

      list:
        html.tag('ul', relations.items),
    }),
};