add day16

This commit is contained in:
Zoe
2022-10-09 15:10:53 -05:00
parent a00c923e08
commit 29e2f8b4e3
30 changed files with 6456 additions and 0 deletions

37
day17/src/entry-client.js Normal file
View File

@@ -0,0 +1,37 @@
import { renderPage, hydratePage } from './lib/router';
import { appState } from '/src/main';
export async function mount(mounted) {
eval(mounted)
}
let SSR
export function isSSR() {
if (!import.meta.env.SSR) {
if (SSR !== undefined) return SSR
SSR = true;
document.head.childNodes.forEach((e) => {
if (e.nodeName == '#comment' && e.textContent == `style-outlet`) {
SSR = false
}
})
return SSR
}
}
if (!import.meta.env.SSR) {
// waits for the page to fully load to render the page from the virtDOM
if (!isSSR()) {
await import('/src/style.css')
await renderPage()
window.onpopstate = async (e) => {
if (e.state === null) {
return
}
await renderPage()
}
} else {
hydratePage()
}
}