« get me outta code hell

generateArtistInfoPageChunk.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/generateArtistInfoPageChunk.js
blob: 121cf43ddd713db73141801172837cc4f76af6f9 (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
export default {
  extraDependencies: ['html', 'language'],

  slots: {
    albumLink: {type: 'html'},

    date: {validate: v => v.isDate},
    duration: {validate: v => v.isDuration},
    durationApproximate: {type: 'boolean'},

    items: {type: 'html'},
  },

  generate(slots, {html, language}) {
    let accentedLink = slots.albumLink;

    accent: {
      const options = {album: accentedLink};
      const parts = ['artistPage.creditList.album'];

      if (slots.date) {
        parts.push('withDate');
        options.date = language.formatDate(slots.date);
      }

      if (slots.duration) {
        parts.push('withDuration');
        options.duration =
          language.formatDuration(slots.duration, {
            approximate: slots.durationApproximate,
          });
      }

      accentedLink = language.formatString(parts.join('.'), options);
    }

    return html.tags([
      html.tag('dt', accentedLink),
      html.tag('dd',
        html.tag('ul',
          slots.items)),
    ]);
  },
};