« get me outta code hell

generateCommentaryContentHeading.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/generateCommentaryContentHeading.js
blob: 924050105d7b9d41a5a616cf7d546c7412a708e6 (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
export default {
  contentDependencies: ['generateContentContentHeading'],
  extraDependencies: ['language'],

  relations: (relation, thing) => ({
    contentContentHeading:
      relation('generateContentContentHeading', thing),
  }),

  data: (thing) => ({
    hasWikiEditorCommentary:
      thing.commentary
        .some(entry => entry.isWikiEditorCommentary),

    onlyWikiEditorCommentary:
      thing.commentary
        .every(entry => entry.isWikiEditorCommentary),
  }),

  generate: (data, relations, {language}) =>
    relations.contentContentHeading.slots({
      // It's #artist-commentary for legacy reasons... Sorry...
      attributes: {id: 'artist-commentary'},

      string:
        language.encapsulate('misc.artistCommentary', capsule =>
          (data.onlyWikiEditorCommentary
            ? language.encapsulate(capsule, 'onlyWikiCommentary')
         : data.hasWikiEditorCommentary
            ? language.encapsulate(capsule, 'withWikiCommentary')
            : capsule)),
    }),
};