mirror of
https://github.com/IT4Change/boilerplate-frontend.git
synced 2025-12-13 07:35:53 +00:00
update renderer
This commit is contained in:
parent
5f529ebebe
commit
3dcf0b89a8
@ -2,6 +2,7 @@ import { renderToString as renderToString_ } from '@vue/server-renderer'
|
|||||||
import { escapeInject, dangerouslySkipEscape } from 'vike/server'
|
import { escapeInject, dangerouslySkipEscape } from 'vike/server'
|
||||||
|
|
||||||
import logoUrl from '#assets/favicon.ico'
|
import logoUrl from '#assets/favicon.ico'
|
||||||
|
import { META } from '#src/env'
|
||||||
|
|
||||||
import { createApp } from './app'
|
import { createApp } from './app'
|
||||||
|
|
||||||
@ -9,20 +10,23 @@ import type { PageContextServer } from '#types/PageContext'
|
|||||||
import type { App } from 'vue'
|
import type { App } from 'vue'
|
||||||
|
|
||||||
// See https://vike.dev/data-fetching
|
// See https://vike.dev/data-fetching
|
||||||
export const passToClient = ['pageProps', 'urlPathname']
|
export const passToClient = ['pageProps', 'urlPathname', 'routeParams']
|
||||||
|
|
||||||
async function render(pageContext: PageContextServer) {
|
async function render(pageContext: PageContextServer) {
|
||||||
const { Page, pageProps } = pageContext
|
const { Page, pageProps } = pageContext
|
||||||
// This render() hook only supports SSR, see https://vike.dev/render-modes for how to modify render() to support SPA
|
// This render() hook only supports SSR, see https://vike.dev/render-modes for how to modify render() to support SPA
|
||||||
if (!Page) throw new Error('My render() hook expects pageContext.Page to be defined')
|
if (!Page) {
|
||||||
|
throw new Error('My render() hook expects pageContext.Page to be defined')
|
||||||
|
}
|
||||||
|
|
||||||
const app = createApp(Page, pageProps, pageContext)
|
const app = createApp(Page, pageProps, pageContext)
|
||||||
|
|
||||||
const appHtml = await renderToString(app)
|
const appHtml = await renderToString(app)
|
||||||
|
|
||||||
// See https://vike.dev/head
|
// See https://vike.dev/head
|
||||||
const { documentProps } = pageContext.exports
|
const { documentProps } = pageContext.exports
|
||||||
const title = (documentProps && documentProps.title) || 'Vite SSR app'
|
const title = (documentProps && documentProps.title) || META.DEFAULT_TITLE
|
||||||
const desc = (documentProps && documentProps.description) || 'App using Vite + Vike'
|
const desc = (documentProps && documentProps.description) || META.DEFAULT_DESCRIPTION
|
||||||
|
|
||||||
const documentHtml = escapeInject`<!DOCTYPE html>
|
const documentHtml = escapeInject`<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user