« get me outta code hell

generatePreviousNextLinks.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/generatePreviousNextLinks.js
blob: e3417cb848501fd4fc7f5632f9f77c9b8db66f2e (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
export default {
  // Returns an array with the slotted previous and next links, prepared
  // for inclusion in a page's navigation bar. Include with other links
  // in the nav bar and then join them all as a unit list, for example.

  extraDependencies: ['html', 'language'],

  slots: {
    previousLink: {type: 'html'},
    nextLink: {type: 'html'},
    id: {type: 'boolean', default: true},
  },

  generate(slots, {html, language}) {
    const previousNext = [];

    if (!html.isBlank(slots.previousLink)) {
      previousNext.push(
        slots.previousLink.slots({
          tooltip: true,
          color: false,
          attributes: {id: slots.id && 'previous-button'},
          content: language.$('misc.nav.previous'),
        }));
    }

    if (!html.isBlank(slots.nextLink)) {
      previousNext.push(
        slots.nextLink.slots({
          tooltip: true,
          color: false,
          attributes: {id: slots.id && 'next-button'},
          content: language.$('misc.nav.next'),
        }));
    }

    return previousNext;
  },
};