« get me outta code hell

generateFlashActNavAccent.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/generateFlashActNavAccent.js
blob: c4ec77b8e434c0b7fc87262fb1d47c3004b225cf (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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import {atOffset} from '#sugar';

export default {
  contentDependencies: [
    'generateInterpageDotSwitcher',
    'generateNextLink',
    'generatePreviousLink',
    'linkFlashAct',
  ],

  extraDependencies: ['wikiData'],

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

  query(sprawl, flashAct) {
    // Like with generateFlashNavAccent, don't sort chronologically here.
    const flashActs =
      sprawl.flashActData;

    const index =
      flashActs.indexOf(flashAct);

    const previousFlashAct =
      atOffset(flashActs, index, -1);

    const nextFlashAct =
      atOffset(flashActs, index, +1);

    return {previousFlashAct, nextFlashAct};
  },

  relations: (relation, query) => ({
    switcher:
      relation('generateInterpageDotSwitcher'),

    previousLink:
      relation('generatePreviousLink'),

    nextLink:
      relation('generateNextLink'),

    previousFlashActLink:
      (query.previousFlashAct
        ? relation('linkFlashAct', query.previousFlashAct)
        : null),

    nextFlashActLink:
      (query.nextFlashAct
        ? relation('linkFlashAct', query.nextFlashAct)
        : null),
  }),

  generate: (relations) =>
    relations.switcher.slots({
      links: [
        relations.previousLink
          .slot('link', relations.previousFlashActLink),

        relations.nextLink
          .slot('link', relations.nextFlashActLink),
      ],
    }),
};