« get me outta code hell

generateRelationsContentHeading.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/generateRelationsContentHeading.js
blob: 5d50c2fc9620902bcc3bf62b65c02fcc4e4e5aa1 (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 {
  relations: (relation, _thing) => ({
    contentHeading:
      relation('generateContentHeading'),
  }),

  data: (nameSlot, thing) => ({
    nameSlot,

    name: thing.name,
    nameStyle: thing.nameStyle,
  }),

  slots: {
    attributes: {type: 'attributes', mutable: false},
    string: {type: 'string'},
  },

  generate(data, relations, slots, {html, language}) {
    const namePart =
      (data.nameStyle === 'utility'
        ? null
        : html.tag('i', data.name));

    const title =
      (namePart
        ? language.$(slots.string, {[data.nameSlot]: namePart})
        : language.$(slots.string, 'withoutName'));

    const stickyTitle =
      language.$(slots.string, 'sticky');

    return relations.contentHeading.slots({
      attributes: slots.attributes,
      title,
      stickyTitle,
    });
  },
};