-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
89 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export default { | ||
passToClient: [ | ||
'errorWhileRendering', | ||
'errorMessage', | ||
'statusCode', | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { createApp } from './error-app' | ||
import type { PageContext } from '../../renderer/types' | ||
|
||
export { onRenderClient } | ||
|
||
async function onRenderClient(pageContext: PageContext) { | ||
const params = createApp(pageContext) | ||
params.app.mount('#app') | ||
} |
13 changes: 3 additions & 10 deletions
13
web/renderer/_error.page.server.ts → web/pages/_error/+onRenderHtml.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
export default { | ||
passToClient: [ | ||
'vueQueryState', | ||
'piniaState', | ||
'errorWhileRendering', | ||
'envConfig', | ||
'validated', | ||
'statusCode', | ||
'redirectTo', | ||
'refs', | ||
'localeMessages', | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { renderToString } from '@vue/server-renderer' | ||
import { dangerouslySkipEscape, escapeInject } from 'vike/server' | ||
import { createApp } from './app' | ||
import type { PageContext } from './types' | ||
import type { PageContextBuiltInServer } from 'vike/types' | ||
import { dehydrate } from '@tanstack/vue-query' | ||
import { renderSSRHead } from '@unhead/ssr' | ||
import SuperJSON from 'superjson' | ||
|
||
export { onRenderHtml } | ||
|
||
async function onRenderHtml(pageContext: PageContextBuiltInServer & PageContext) { | ||
const { app, head, pinia, router, queryClient } = createApp(pageContext) | ||
|
||
let firstError: unknown = undefined | ||
app.config.errorHandler = (err) => { | ||
firstError = firstError ?? err | ||
return false | ||
} | ||
router.push(pageContext.urlOriginal) | ||
await router.isReady() | ||
|
||
let string = await renderToString(app) | ||
if (firstError) { | ||
throw firstError | ||
} | ||
|
||
const payload = await renderSSRHead(head) | ||
const vueQueryState = dehydrate(queryClient) | ||
const piniaState = SuperJSON.stringify(pinia.state.value) | ||
|
||
const documentHtml = escapeInject`<!DOCTYPE html> | ||
<html${dangerouslySkipEscape(payload.htmlAttrs)}> | ||
<head> | ||
${dangerouslySkipEscape(payload.headTags)} | ||
</head> | ||
<body${dangerouslySkipEscape(payload.bodyAttrs)}> | ||
${dangerouslySkipEscape(payload.bodyTagsOpen)} | ||
<div id="app">${dangerouslySkipEscape(string)}</div> | ||
${dangerouslySkipEscape(payload.bodyTags)} | ||
</body> | ||
</html>` | ||
|
||
return { | ||
documentHtml, | ||
pageContext: { | ||
vueQueryState, | ||
piniaState, | ||
}, | ||
} | ||
} |
File renamed without changes.
This file was deleted.
Oops, something went wrong.