-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdefault.root.layout.js
More file actions
61 lines (59 loc) · 1.73 KB
/
default.root.layout.js
File metadata and controls
61 lines (59 loc) · 1.73 KB
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
/**
* @import { LayoutFunction } from '../../index.js'
* @import { VNode } from 'preact'
*/
import { html } from 'htm/preact'
import { render } from 'preact-render-to-string'
/**
* @typedef {{
* title: string,
* siteName: string,
* defaultStyle: boolean,
* basePath: string
* }} DefaultRootLayoutVars
*/
/**
* Build all of the bundles using esbuild.
*
* @type {LayoutFunction<DefaultRootLayoutVars, string | VNode, string>}
*/
export default function defaultRootLayout ({
vars: {
title,
siteName = 'domstack',
basePath,
/* defaultStyle = true Set this to false in global or page to disable the default style in the default layout */
},
scripts,
styles,
children,
/* pages */
/* page */
}) {
return /* html */`
<!DOCTYPE html>
<html>
${render(html`
<head>
<meta charset="utf-8" />
<title>${title ? `${title}` : ''}${title && siteName ? ' | ' : ''}${siteName}</title>
<meta name="viewport" content="width=device-width, user-scalable=no" />
${scripts
? scripts.map(script => html`<script type='module' src="${script.startsWith('/') ? `${basePath ?? ''}${script}` : script}" />`)
: null}
${styles
? styles.map(style => html`<link rel="stylesheet" href="${style.startsWith('/') ? `${basePath ?? ''}${style}` : style}" />`)
: null}
</head>
`)}
${render(html`
<body className="safe-area-inset">
${typeof children === 'string'
? html`<main className="mine-layout app-main" dangerouslySetInnerHTML="${{ __html: children }}"/>`
: html`<main className="mine-layout app-main">${children}</main>`
}
</body>
`)}
</html>
`
}