Skip to content

Black Friday

Annual Pro is $90 for the first year, normally $120. Or start monthly at $6 for two months, then $12.

Ends Dec 4, 11:59 PM PT.

Create an account
← Public packages

@kody/example-habit-log

A small habit log app built from the app starter: indigo theme, mobile layout, sign-in, and saved entries.

FollowFork

Files

document.tsx

45 lines · 1.3 KB · TypeScript
import type { ReactNode } from 'react'
import type { RouterContext } from './router-context.ts'

/** The HTML shell. Boot data for the browser rides on `data-*` attributes. */
export function Document(props: {
	context: RouterContext
	title: string
	children: ReactNode
}) {
	const { context } = props
	const assetBase = context.assetBasePath.replace(/\/$/, '')
	return (
		<html
			lang="en"
			data-app-base={context.appBasePath}
			data-asset-base={assetBase}
			data-hosted-url={context.hostedUrl ?? ''}
			data-visitor={context.visitor ? JSON.stringify(context.visitor) : ''}
		>
			<head>
				<meta charSet="utf-8" />
				<meta name="viewport" content="width=device-width, initial-scale=1" />
				<meta name="color-scheme" content="light dark" />
				<title>{props.title}</title>
				<link rel="stylesheet" href={`${assetBase}/tokens.css`} />
				<link rel="stylesheet" href={`${assetBase}/styles.css`} />
			</head>
			<body>
				{props.children}
				{context.dehydratedState ? (
					<script
						id="query-state"
						type="application/json"
						dangerouslySetInnerHTML={{
							__html: JSON.stringify(context.dehydratedState).replace(/</g, '\\u003c'),
						}}
					/>
				) : null}
				{context.clientModuleUrl ? (
					<script type="module" src={context.clientModuleUrl} />
				) : null}
			</body>
		</html>
	)
}