brf/server/templates/public.ts
2025-11-24 17:09:09 +01:00

29 lines
1.1 KiB
TypeScript

import html from '../lib/html.ts'
export default ({ content, css, head, preload, script, state }) => html`<!DOCTYPE html>
<html lang='sv-SE'>
<head>
<link rel="icon" href="/favicon.svg" />
<script type="module" src="${script}"></script>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<meta name="robots" content="index, follow" />
${css?.map((href) => `<link rel='stylesheet' crossorigin href='${href}'>`)}
${preload?.map((href) => `<link rel='modulepreload' crossorigin href='${href}'>`)}
<title>${head?.then((head) => head.title)}</title>
${head?.then((head) =>
head.tags?.map(
(tag) =>
`<${tag.type} ${Object.entries(tag.attributes)
.map(([name, content]) => `${name}='${content}'`)
.join(' ')}/>`,
),
)}
</head>
<body>
${content}
${state?.then((state) => `<script>window.__STATE__ = ${JSON.stringify(state)}</script>`)}
<script>var offset=window.history.state&&window.history.state.scrollTop||0;if(offset)window.scrollTo(0,offset)</script>
</body>
</html>`