« get me outta code hell

generateAlbumLinkNavAccent.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/generateAlbumLinkNavAccent.js
blob: 50a5347291100f4a6dfef63fb63a10cbc2520bfa (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
export default {
  data: (album) => ({
    style:
      album.style,

    nameDetail:
      album.nameDetail,
  }),

  slots: {
    navString: {type: 'string', default: 'albumPage.nav'},
  },

  generate: (data, slots, {html, language}) =>
    language.encapsulate(slots.navString, 'albumAccent', capsule => {
      let workingCapsule = capsule;
      let workingOptions = {};

      let any = false;

      if (data.nameDetail) {
        workingCapsule += '.withNameDetail';
        workingOptions.nameDetail = data.nameDetail;
        any = true;
      }

      const type =
        (data.style === 'single'
          ? language.$(capsule, 'type.single')
       : data.style === 'in-game vgm'
          ? language.$(capsule, 'type.vgm')
          : html.blank());

      if (!html.isBlank(type)) {
        workingCapsule += '.withType';
        workingOptions.type = type;
        any = true;
      }

      if (any) {
        return language.$(workingCapsule, workingOptions);
      } else {
        return html.blank();
      }
    }),
};