-
-
Notifications
You must be signed in to change notification settings - Fork 27
/
index.tsx
52 lines (48 loc) · 956 Bytes
/
index.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import {
LocationProvider,
Router,
Route,
hydrate,
prerender as ssr,
} from "preact-iso";
import { Header } from "./components/Header.jsx";
import { Home } from "./pages/Home/index.jsx";
import { NotFound } from "./pages/_404.jsx";
import "./style.css";
export function App() {
return (
<LocationProvider>
<Header />
<main>
<Router>
<Route path="/" component={Home} />
<Route default component={NotFound} />
</Router>
</main>
</LocationProvider>
);
}
if (typeof window !== "undefined") {
hydrate(<App />, document.getElementById("app"));
}
export async function prerender(data) {
const { html, links } = await ssr(<App />);
return {
html,
links,
data: { url: data.url },
head: {
lang: "en",
title: "Prerendered Preact App",
elements: new Set([
{
type: "meta",
props: {
name: "description",
content: "This is a prerendered Preact app",
},
},
]),
},
};
}