24 lines
616 B
JavaScript
24 lines
616 B
JavaScript
// `usePageContext` allows us to access `pageContext` in any Vue component.
|
|
// See https://vike.dev/pageContext-anywhere
|
|
|
|
import { inject } from 'vue';
|
|
|
|
const key = Symbol(); // eslint-disable-line symbol-description
|
|
let localPageContext = null; // eslint-disable-line import/no-mutable-exports
|
|
|
|
export function usePageContext() {
|
|
const pageContext = inject(key);
|
|
return pageContext;
|
|
}
|
|
|
|
export function getPageContext() {
|
|
return localPageContext;
|
|
}
|
|
|
|
export function setPageContext(app, pageContext) {
|
|
localPageContext = pageContext;
|
|
app.provide(key, pageContext);
|
|
}
|
|
|
|
export { localPageContext as pageContext };
|