-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdefault.root.layout.js
53 lines (51 loc) · 1.49 KB
/
default.root.layout.js
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
// @ts-ignore
import { html, render } from 'uhtml-isomorphic'
/**
* @template T extends object
* @typedef {import('../build-pages/resolve-layout.js').LayoutFunction<T>} LayoutFunction
*/
/**
* Build all of the bundles using esbuild.
*
* @type {LayoutFunction<{
* title: string,
* siteName: string,
* defaultStyle: boolean,
* basePath: string
* }>}
*/
export default function defaultRootLayout ({
vars: {
title,
siteName = 'TopBun',
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 render(String, html`
<!DOCTYPE html>
<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}"></script>`)
: null}
${styles
? styles.map(style => html`<link rel="stylesheet" href="${style.startsWith('/') ? `${basePath ?? ''}${style}` : style}" />`)
: null}
</head>
<body class="safe-area-inset">
<main class="mine-layout">
${typeof children === 'string' ? html([children]) : children /* Support both uhtml and string children. Optional. */}
</main>
</body>
</html>
`)
}