mirror of
https://github.com/IT4Change/boilerplate-frontend.git
synced 2025-12-13 07:35:53 +00:00
migrate vike
This commit is contained in:
parent
684c47e31c
commit
3b430cd69a
6
renderer/+config.h.ts
Normal file
6
renderer/+config.h.ts
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
// See https://vike.dev/data-fetching
|
||||||
|
export default {
|
||||||
|
clientRouting: true,
|
||||||
|
prefetchStaticAssets: 'viewport',
|
||||||
|
passToClient: ['pageProps', /* 'urlPathname', */ 'routeParams']
|
||||||
|
}
|
||||||
5
renderer/+onHydrationEnd.ts
Normal file
5
renderer/+onHydrationEnd.ts
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
function onHydrationEnd() {
|
||||||
|
// console.log('Hydration finished; page is now interactive.')
|
||||||
|
}
|
||||||
|
|
||||||
|
export { onHydrationEnd }
|
||||||
6
renderer/+onPageTransitionEnd.ts
Normal file
6
renderer/+onPageTransitionEnd.ts
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
function onPageTransitionEnd() {
|
||||||
|
// console.log('Page transition end')
|
||||||
|
// document.body.classList.remove('page-transition')
|
||||||
|
}
|
||||||
|
|
||||||
|
export { onPageTransitionEnd }
|
||||||
6
renderer/+onPageTransitionStart.ts
Normal file
6
renderer/+onPageTransitionStart.ts
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
function onPageTransitionStart() {
|
||||||
|
// console.log('Page transition start')
|
||||||
|
// document.body.classList.add('page-transition')
|
||||||
|
}
|
||||||
|
|
||||||
|
export { onPageTransitionStart }
|
||||||
15
renderer/+onRenderClient.ts
Normal file
15
renderer/+onRenderClient.ts
Normal 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
|
||||||
@ -9,9 +9,6 @@ import { createApp } from './app'
|
|||||||
import type { PageContextServer, PageContext } from '#types/PageContext'
|
import type { PageContextServer, PageContext } from '#types/PageContext'
|
||||||
import type { App } from 'vue'
|
import type { App } from 'vue'
|
||||||
|
|
||||||
// See https://vike.dev/data-fetching
|
|
||||||
export const passToClient = ['pageProps', /* 'urlPathname', */ 'routeParams']
|
|
||||||
|
|
||||||
async function render(pageContext: PageContextServer & PageContext) {
|
async function render(pageContext: PageContextServer & PageContext) {
|
||||||
const { app, i18n } = createApp(pageContext, false)
|
const { app, i18n } = createApp(pageContext, false)
|
||||||
|
|
||||||
@ -57,4 +54,4 @@ async function renderToString(app: App) {
|
|||||||
return appHtml
|
return appHtml
|
||||||
}
|
}
|
||||||
|
|
||||||
export { render }
|
export default render
|
||||||
@ -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 }
|
|
||||||
@ -1,6 +1,6 @@
|
|||||||
import type { PageContextBuiltInServer } from 'vike/types'
|
import type { PageContextBuiltInServer } from 'vike/types'
|
||||||
|
|
||||||
export { onBeforeRender }
|
export default onBeforeRender
|
||||||
|
|
||||||
/* async */ function onBeforeRender(pageContext: PageContextBuiltInServer) {
|
/* async */ function onBeforeRender(pageContext: PageContextBuiltInServer) {
|
||||||
return {
|
return {
|
||||||
Loading…
x
Reference in New Issue
Block a user