test vite ssr

This commit is contained in:
polv committed 2022-05-07 19:28:04 +07:00
1 parent 6725bf89ad
commit 066f94188a
20 files changed
+406

No files matched your search

@@ -0,0 +1,21 @@
// Hook `usePageContext()` to make `pageContext` available from any Vue component.
// See https://vite-plugin-ssr.com/pageContext-anywhere
import { inject } from 'vue'
import type { App, InjectionKey } from 'vue'
import { PageContext } from './types'
export { usePageContext }
export { setPageContext }
const key: InjectionKey<PageContext> = Symbol()
function usePageContext() {
const pageContext = inject(key)
if (!pageContext) throw new Error("setPageContext() not called in parent")
return pageContext
}
function setPageContext(app: App, pageContext: PageContext) {
app.provide(key, pageContext)
}