« get me outta code hell

generatePageLayout.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/generatePageLayout.js
blob: b27d487bd956c48196fe5a7f0f9ac46fadaacecb (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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
import {empty} from '../../util/sugar.js';

export default {
  extraDependencies: [
    'html',
    'language',
    'to',
  ],

  generate({
    cachebust,
    html,
    language,
    to,
  }) {
    return html.template(slot =>
      slot('title', ([...title]) =>
      slot('headingMode', ([headingMode = 'static']) => {
        let titleHTML = null;

        if (!empty(title)) {
          if (headingMode === 'sticky') {
            /*
              generateStickyHeadingContainer({
                coverSrc: cover.src,
                coverAlt: cover.alt,
                coverArtTags: cover.artTags,
                title,
              })
            */
          } else if (headingMode === 'static') {
            titleHTML = html.tag('h1', title);
          }
        }

        const mainHTML =
          html.tag('main', {
            id: 'content',
            class: slot('mainClass'),
          }, [
            titleHTML,

            slot('cover'),

            html.tag('div',
              {
                [html.onlyIfContent]: true,
                class: 'main-content-container',
              },
              slot('mainContent')),
          ]);

        const layoutHTML = [
          // navHTML,
          // banner.position === 'top' && bannerHTML,
          // secondaryNavHTML,
          html.tag('div',
            {
              class: [
                'layout-columns',
                // !collapseSidebars && 'vertical-when-thin',
                // (sidebarLeftHTML || sidebarRightHTML) && 'has-one-sidebar',
                // (sidebarLeftHTML && sidebarRightHTML) && 'has-two-sidebars',
                // !(sidebarLeftHTML || sidebarRightHTML) && 'has-zero-sidebars',
                // sidebarLeftHTML && 'has-sidebar-left',
                // sidebarRightHTML && 'has-sidebar-right',
              ],
            },
            [
              // sidebarLeftHTML,
              mainHTML,
              // sidebarRightHTML,
            ]),
          // banner.position === 'bottom' && bannerHTML,
          // footerHTML,
        ].filter(Boolean).join('\n');

        const documentHTML = html.tags([
          `<!DOCTYPE html>`,
          html.tag('html',
            {
              lang: language.intlCode,
              'data-language-code': language.code,

              /*
              'data-url-key': 'localized.' + pagePath[0],
              ...Object.fromEntries(
                pagePath.slice(1).map((v, i) => [['data-url-value' + i], v])),
              */

              'data-rebase-localized': to('localized.root'),
              'data-rebase-shared': to('shared.root'),
              'data-rebase-media': to('media.root'),
              'data-rebase-data': to('data.root'),
            },
            [
              // developersComment,

              html.tag('head', [
                /*
                html.tag('title',
                  showWikiNameInTitle
                    ? language.formatString('misc.pageTitle.withWikiName', {
                        title,
                        wikiName: wikiInfo.nameShort,
                      })
                    : language.formatString('misc.pageTitle', {title})),
                */

                html.tag('meta', {charset: 'utf-8'}),
                html.tag('meta', {
                  name: 'viewport',
                  content: 'width=device-width, initial-scale=1',
                }),

                /*
                ...(
                  Object.entries(meta)
                    .filter(([key, value]) => value)
                    .map(([key, value]) => html.tag('meta', {[key]: value}))),

                canonical &&
                  html.tag('link', {
                    rel: 'canonical',
                    href: canonical,
                  }),

                ...(
                  localizedCanonical
                    .map(({lang, href}) => html.tag('link', {
                      rel: 'alternate',
                      hreflang: lang,
                      href,
                    }))),

                */

                // slot('socialEmbed'),

                html.tag('link', {
                  rel: 'stylesheet',
                  href: to('shared.staticFile', `site3.css?${cachebust}`),
                }),

                /*
                html.tag('style',
                  {[html.onlyIfContent]: true},
                  [
                    theme,
                    stylesheet,
                  ]),
                */

                html.tag('script', {
                  src: to('shared.staticFile', `lazy-loading.js?${cachebust}`),
                }),
              ]),

              html.tag('body',
                // {style: body.style || ''},
                [
                  html.tag('div', {id: 'page-container'}, [
                    // mainHTML && skippersHTML,
                    layoutHTML,
                  ]),

                  // infoCardHTML,
                  // imageOverlayHTML,

                  html.tag('script', {
                    type: 'module',
                    src: to('shared.staticFile', `client.js?${cachebust}`),
                  }),
                ]),
            ])
        ]);

        return documentHTML;
      })));
  },
};