30 lines
783 B
JavaScript
30 lines
783 B
JavaScript
import { html, render } from '../templater.js'
|
|
|
|
async function Root (ctx, component, ...params) {
|
|
const result = await render(ctx, component, ...params)
|
|
const scripts = Array.from(result.js).join(';\n')
|
|
const css = Array.from(result.css).join('\n')
|
|
|
|
return html`
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
|
${Array.from(result.head).join('\n')}
|
|
<style>
|
|
${css}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
${result.body}
|
|
${scripts ? `<script>${scripts}</script>` : ''}
|
|
</body>
|
|
</html>
|
|
`
|
|
}
|
|
|
|
export function page(component, ...params) {
|
|
return render(null, Root, component, ...params)
|
|
}
|