2021-10-12 19:21:49 +09:00
|
|
|
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) {
|
2021-10-13 19:50:32 +09:00
|
|
|
const html = renderToString(
|
2021-10-12 19:21:49 +09:00
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<title>vite-ssg-example</title>
|
|
|
|
</head>
|
2021-10-13 19:50:32 +09:00
|
|
|
<body>
|
|
|
|
<pageContext.Page />
|
|
|
|
</body>
|
|
|
|
</html>
|
|
|
|
);
|
|
|
|
|
|
|
|
return escapeInject`<!DOCTYPE html>${dangerouslySkipEscape(html)}`;
|
2021-10-12 19:21:49 +09:00
|
|
|
}
|