« get me outta code hell

generateGroupInfoPageAlbumsListByDate.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/generateGroupInfoPageAlbumsListByDate.js
blob: 079cb56ca4ac83bf7194f09dc3785ed8d0f0b4da (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
import {sortChronologically} from '#sort';

export default {
  contentDependencies: ['generateGroupInfoPageAlbumsListItem'],

  extraDependencies: ['html'],

  query: (group) => ({
    // Typically, a latestFirst: false (default) chronological sort would be
    // appropriate here, but navigation between adjacent albums in a group is a
    // rather "essential" movement or relationship in the wiki, and we consider
    // the sorting order of a group's gallery page (latestFirst: true) to be
    // "canonical" in this regard. We exactly match its sort here, but reverse
    // it, to still present earlier albums preceding later ones.
    albums:
      sortChronologically(group.albums.slice(), {latestFirst: true})
        .reverse(),
  }),

  relations: (relation, query, group) => ({
    items:
      query.albums
        .map(album =>
          relation('generateGroupInfoPageAlbumsListItem',
            album,
            group)),
  }),

  slots: {
    hidden: {
      type: 'boolean',
      default: false,
    },
  },

  generate: (relations, slots, {html}) =>
    html.tag('ul',
      {id: 'group-album-list-by-date'},

      slots.hidden && {style: 'display: none'},

      {[html.onlyIfContent]: true},

      relations.items),
};