-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdocument.jsx
34 lines (32 loc) · 1.16 KB
/
document.jsx
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
export default async function* ({ children }) {
const data = [];
// TODO: with hydration rendering, I don't need the following
// in order to save server rendering-time data.
if (this.$isServer) {
this.$bus.on('data', (id, content) => {
data.push({ id, content: Buffer.from(JSON.stringify(content)).toString('base64')});
this.refresh();
});
}
for await ({} of this) {
yield (
<html>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
{data.map(({ id, content }) => (
<meta name="ssr" data-id={id} data-content={content} />
))}
<title>Pedal</title>
<link rel="stylesheet" href="/client.css"></link>
</head>
<body>
<div id="root" data-ssr>
{children}
</div>
<script src="/client.js" type="module"></script>
</body>
</html>
);
}
}