« get me outta code hell

generateListRandomPageLinksAllAlbumsSection.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/generateListRandomPageLinksAllAlbumsSection.js
blob: e03252c9d510070e94fe0f6cc5e3d1875efd7f59 (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
import {sortChronologically} from '#wiki-data';

export default {
  contentDependencies: ['generateListRandomPageLinksAlbumLink', 'linkGroup'],
  extraDependencies: ['html', 'language', 'wikiData'],

  sprawl: ({albumData}) => ({albumData}),

  query: (sprawl) => ({
    albums:
      sortChronologically(sprawl.albumData.slice())
        .filter(album => album.tracks.length > 1),
  }),

  relations: (relation, query) => ({
    albumLinks:
      query.albums
        .map(album => relation('generateListRandomPageLinksAlbumLink', album)),
  }),

  generate: (relations, {html, language}) =>
    html.tags([
      html.tag('dt',
        language.$('listingPage.other.randomPages.fromAlbum')),

      html.tag('dd',
        html.tag('ul',
          relations.albumLinks
            .map(albumLink =>
              html.tag('li',
                language.$('listingPage.other.randomPages.album', {
                  album: albumLink,
                }))))),
    ]),
};