« get me outta code hell

linkAlbum.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/linkAlbum.js
blob: f012369a50acbe524c4c7c420761034371b9ad2c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
export default {
  contentDependencies: ['linkThing', 'linkTrack'],
  extraDependencies: ['language'],

  relations: (relation, album) => ({
    link:
      (album.style === 'single'
        ? relation('linkTrack', album.tracks[0])
        : relation('linkThing', 'localized.album', album)),
  }),

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

  generate: (data, relations, {language}) =>
    (data.style === 'single'
      ? relations.link.slot('content', language.sanitize(data.name))
      : relations.link),
};