mirror of
https://github.com/kou029w/_.git
synced 2025-01-31 14:28:04 +00:00
16 lines
511 B
TypeScript
16 lines
511 B
TypeScript
import renderToString from "preact-render-to-string";
|
|
import { escapeInject, dangerouslySkipEscape } from "vite-plugin-ssr";
|
|
import type { PageContextBuiltIn } from "vite-plugin-ssr/types";
|
|
|
|
export async function render(pageContext: PageContextBuiltIn) {
|
|
const { Page } = pageContext;
|
|
const html = renderToString(<Page />);
|
|
|
|
return escapeInject`<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<title>vite-ssg-example</title>
|
|
</head>
|
|
<body>${dangerouslySkipEscape(html)}</body>
|
|
</html>`;
|
|
}
|