« 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: af6c3ed9928eec9979f50458b5a717cda75a24de (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
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)),
  }),

  generate: (relations, {html}) =>
    html.tag('ul',
      {[html.onlyIfContent]: true},

      relations.items),
};