« get me outta code hell

generateAlbumInfoPage.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/generateAlbumInfoPage.js
blob: 9e4b8816a480e65bf86ae1a5505a7c1c9d12e864 (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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
export default {
  contentDependencies: [
    'generateAlbumAdditionalFilesList',
    'generateAlbumBanner',
    'generateAlbumCoverArtwork',
    'generateAlbumNavAccent',
    'generateAlbumReleaseInfo',
    'generateAlbumSecondaryNav',
    'generateAlbumSidebar',
    'generateAlbumSocialEmbed',
    'generateAlbumStyleRules',
    'generateAlbumTrackList',
    'generateAlbumChronologyLinks',
    'generateCommentarySection',
    'generateContentHeading',
    'generatePageLayout',
    'linkAlbumCommentary',
    'linkAlbumGallery',
  ],

  extraDependencies: ['html', 'language'],

  relations: (relation, album) => ({
    layout:
      relation('generatePageLayout'),

    albumStyleRules:
      relation('generateAlbumStyleRules', album, null),

    socialEmbed:
      relation('generateAlbumSocialEmbed', album),

    albumNavAccent:
      relation('generateAlbumNavAccent', album, null),

    chronologyLinks:
      relation('generateAlbumChronologyLinks', album),

    secondaryNav:
      relation('generateAlbumSecondaryNav', album),

    sidebar:
      relation('generateAlbumSidebar', album, null),

    cover:
      (album.hasCoverArt
        ? relation('generateAlbumCoverArtwork', album)
        : null),

    banner:
      (album.hasBannerArt
        ? relation('generateAlbumBanner', album)
        : null),

    contentHeading:
      relation('generateContentHeading'),

    releaseInfo:
      relation('generateAlbumReleaseInfo', album),

    galleryLink:
      (album.tracks.some(t => t.hasUniqueCoverArt)
        ? relation('linkAlbumGallery', album)
        : null),

    commentaryLink:
      (album.commentary || album.tracks.some(t => t.commentary)
        ? relation('linkAlbumCommentary', album)
        : null),

    trackList:
      relation('generateAlbumTrackList', album),

    additionalFilesList:
      relation('generateAlbumAdditionalFilesList',
        album,
        album.additionalFiles),

    artistCommentarySection:
      relation('generateCommentarySection', album.commentary),
  }),

  data: (album) => ({
    name:
      album.name,

    color:
      album.color,

    dateAddedToWiki:
      album.dateAddedToWiki,
  }),

  generate: (data, relations, {html, language}) =>
    relations.layout.slots({
      title: language.$('albumPage.title', {album: data.name}),
      headingMode: 'sticky',

      color: data.color,
      styleRules: [relations.albumStyleRules],

      cover:
        relations.cover
          ?.slots({
            alt: language.$('misc.alt.albumCover'),
          })
          ?? null,

      mainContent: [
        relations.releaseInfo,

        html.tag('p',
          {[html.onlyIfContent]: true},
          {[html.joinChildren]: html.tag('br')},

          [
            !html.isBlank(relations.additionalFilesList) &&
              language.$('releaseInfo.additionalFiles.shortcut', {
                link: html.tag('a',
                  {href: '#additional-files'},
                  language.$('releaseInfo.additionalFiles.shortcut.link')),
              }),

            relations.galleryLink && relations.commentaryLink &&
              language.$('releaseInfo.viewGalleryOrCommentary', {
                gallery:
                  relations.galleryLink
                    .slot('content', language.$('releaseInfo.viewGalleryOrCommentary.gallery')),
                commentary:
                  relations.commentaryLink
                    .slot('content', language.$('releaseInfo.viewGalleryOrCommentary.commentary')),
              }),

            relations.galleryLink && !relations.commentaryLink &&
              language.$('releaseInfo.viewGallery', {
                link:
                  relations.galleryLink
                    .slot('content', language.$('releaseInfo.viewGallery.link')),
              }),

            !relations.galleryLink && relations.commentaryLink &&
              language.$('releaseInfo.viewCommentary', {
                link:
                  relations.commentaryLink
                    .slot('content', language.$('releaseInfo.viewCommentary.link')),
              }),
          ]),

        relations.trackList,

        html.tag('p',
          {[html.onlyIfContent]: true},
          {[html.joinChildren]: html.tag('br')},

          [
            language.$('releaseInfo.addedToWiki', {
              [language.onlyIfOptions]: ['date'],
              date: language.formatDate(data.dateAddedToWiki),
            }),
          ]),

        html.tags([
          relations.contentHeading.clone()
            .slots({
              attributes: {id: 'additional-files'},
              title: language.$('releaseInfo.additionalFiles.heading'),
            }),

          relations.additionalFilesList,
        ]),

        relations.artistCommentarySection,
      ],

      navLinkStyle: 'hierarchical',
      navLinks: [
        {auto: 'home'},
        {
          auto: 'current',
          accent:
            relations.albumNavAccent.slots({
              showTrackNavigation: true,
              showExtraLinks: true,
            }),
        },
      ],

      navContent:
        relations.chronologyLinks,

      banner: relations.banner ?? null,
      bannerPosition: 'top',

      secondaryNav: relations.secondaryNav,

      leftSidebar: relations.sidebar,

      socialEmbed: relations.socialEmbed,
    }),
};