« 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: bb22c21fea954c40c277dfe44ad7cd5a77d90f95 (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
export const description = `wiki-wide listing pages & index`;

// 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, each directly identifying the hard-coded content
// function used to generate that listing.
//
// Individual listing specs are described in src/listing-spec.js, but are
// provided via wikiData like other (normal) data objects.
//
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'},
    },
  ];
}