« get me outta code hell

generateCollapsedContentEntrySection.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/generateCollapsedContentEntrySection.js
blob: ae3652c7d6863ef5807921619da2fd1ecfdf397a (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
export default {
  contentDependencies: [
    'generateCommentaryEntry',
    'generateContentContentHeading',
  ],

  extraDependencies: ['html'],

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

    entries:
      entries
        .map(entry => relation('generateCommentaryEntry', entry)),
  }),

  slots: {
    id: {type: 'string'},
    string: {type: 'string'},
  },

  generate: (relations, slots, {html}) =>
    html.tag('details',
      {[html.onlyIfContent]: true},

      slots.id && [
        {class: 'memorable'},
        {'data-memorable-id': slots.id},
      ],

      [
        relations.contentContentHeading.slots({
          attributes: [
            slots.id && {id: slots.id},
          ],

          string: slots.string,
          summary: true,
        }),

        relations.entries,
      ]),
};