···1import express from 'express'
2import type { AppContext } from '#/config'
3+import { home } from '#/pages/home'
4+import { page } from '#/view'
5import { handler } from './util'
67export const createRouter = (ctx: AppContext) => {
···11 '/',
12 handler(async (req, res) => {
13 const posts = await ctx.db.selectFrom('post').selectAll().orderBy('indexedAt', 'desc').limit(10).execute()
14+ return res.type('html').send(page(home(posts)))
015 }),
16 )
17
+12
src/view.ts
···000000000000
···1+// @ts-ignore
2+import ssr from 'uhtml/ssr'
3+import type initSSR from 'uhtml/types/init-ssr'
4+import type { Hole } from 'uhtml/types/keyed'
5+6+export type { Hole }
7+8+export const { html }: ReturnType<typeof initSSR> = ssr()
9+10+export function page(hole: Hole) {
11+ return `<!DOCTYPE html>\n${hole.toDOM().toString()}`
12+}