migrate vike

This commit is contained in:
Ulf Gebhardt 2023-12-27 07:21:29 +01:00
parent 684c47e31c
commit 3b430cd69a
Signed by: ulfgebhardt
GPG Key ID: DA6B843E748679C9
14 changed files with 40 additions and 37 deletions

6
renderer/+config.h.ts Normal file
View File

@ -0,0 +1,6 @@
// See https://vike.dev/data-fetching
export default {
clientRouting: true,
prefetchStaticAssets: 'viewport',
passToClient: ['pageProps', /* 'urlPathname', */ 'routeParams']
}

View File

@ -0,0 +1,5 @@
function onHydrationEnd() {
// console.log('Hydration finished; page is now interactive.')
}
export { onHydrationEnd }

View File

@ -0,0 +1,6 @@
function onPageTransitionEnd() {
// console.log('Page transition end')
// document.body.classList.remove('page-transition')
}
export { onPageTransitionEnd }

View File

@ -0,0 +1,6 @@
function onPageTransitionStart() {
// console.log('Page transition start')
// document.body.classList.add('page-transition')
}
export { onPageTransitionStart }

View File

@ -0,0 +1,15 @@
import { createApp } from './app'
import type { PageContext, VikePageContext } from '#types/PageContext'
let instance: ReturnType<typeof createApp>
/* async */ function render(pageContext: VikePageContext & PageContext) {
if (!instance) {
instance = createApp(pageContext)
instance.app.mount('#app')
} else {
instance.app.changePage(pageContext)
}
}
export default render

View File

@ -9,9 +9,6 @@ import { createApp } from './app'
import type { PageContextServer, PageContext } from '#types/PageContext'
import type { App } from 'vue'
// See https://vike.dev/data-fetching
export const passToClient = ['pageProps', /* 'urlPathname', */ 'routeParams']
async function render(pageContext: PageContextServer & PageContext) {
const { app, i18n } = createApp(pageContext, false)
@ -57,4 +54,4 @@ async function renderToString(app: App) {
return appHtml
}
export { render }
export default render

View File

@ -1,32 +0,0 @@
import { createApp } from './app'
import type { PageContext, VikePageContext } from '#types/PageContext'
let instance: ReturnType<typeof createApp>
/* async */ function render(pageContext: VikePageContext & PageContext) {
if (!instance) {
instance = createApp(pageContext)
instance.app.mount('#app')
} else {
instance.app.changePage(pageContext)
}
}
function onHydrationEnd() {
// console.log('Hydration finished; page is now interactive.')
}
function onPageTransitionStart() {
// console.log('Page transition start')
// document.body.classList.add('page-transition')
}
function onPageTransitionEnd() {
// console.log('Page transition end')
// document.body.classList.remove('page-transition')
}
export const clientRouting = true
export const prefetchStaticAssets = 'viewport'
export { render }
export { onHydrationEnd }
export { onPageTransitionStart }
export { onPageTransitionEnd }

View File

@ -1,6 +1,6 @@
import type { PageContextBuiltInServer } from 'vike/types'
export { onBeforeRender }
export default onBeforeRender
/* async */ function onBeforeRender(pageContext: PageContextBuiltInServer) {
return {