« get me outta code hell

generateCoverArtwork.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/generateCoverArtwork.js
blob: 62fc35662bb1e52234cfe44f4e36ce5d6ddc2add (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
import {empty} from '../../util/sugar.js';

export default {
  contentDependencies: ['image', 'linkArtTag'],
  extraDependencies: ['html', 'language'],

  relations(relation, artTags) {
    const relations = {};

    relations.image =
      relation('image', artTags);

    if (artTags) {
      relations.tagLinks =
        artTags
          .filter(tag => !tag.isContentWarning)
          .map(tag => relation('linkArtTag', tag));
    } else {
      relations.tagLinks = null;
    }

    return relations;
  },

  generate(relations, {html, language}) {
    return html.template(slot =>
      html.tag('div', {id: 'cover-art-container'}, [
        relations.image
          .slot('path', slot('path'))
          .slot('alt', slot('alt'))
          .slot('thumb', 'medium')
          .slot('id', 'cover-art')
          .slot('link', true)
          .slot('square', true),

        !empty(relations.tagLinks) &&
          html.tag('p',
            language.$('releaseInfo.artTags.inline', {
              tags: language.formatUnitList(relations.tagLinks),
            })),
      ]));
  },
};