« get me outta code hell

listing.js « page « src - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/page/listing.js
blob: 64db413d58528e2c23da76b6ad568b2058c9a328 (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
46
47
// Listing page specification.
//
// The targets here are a bit different than for most pages: rather than data
// objects loaded from text files in the wiki data directory, they're hard-
// coded specifications, with various JS functions for processing wiki data
// and turning it into user-readable HTML listings.
//
// Individual listing specs are described in src/listing-spec.js, but are
// provided via wikiData like other (normal) data objects.

import {empty} from '../util/sugar.js';

import {getTotalDuration} from '../util/wiki-data.js';

export const description = `wiki-wide listing pages & index`;

export function targets({wikiData}) {
  return (
    wikiData.listingSpec
      .filter(listing => listing.contentFunction)
      .filter(listing =>
        !listing.featureFlag ||
        wikiData.wikiInfo[listing.featureFlag]));
}

export function pathsForTarget(listing) {
  return [
    {
      type: 'page',
      path: ['listing', listing.directory],
      contentFunction: {
        name: listing.contentFunction,
        args: [listing],
      },
    },
  ];
}

export function pathsTargetless() {
  return [
    {
      type: 'page',
      path: ['listingIndex'],
      contentFunction: {name: 'generateListingsIndexPage'},
    },
  ];
}