shack/renderer/usePageContext.js

20 lines
407 B
JavaScript

// `usePageContext` allows us to access `pageContext` in any Vue component.
// See https://vite-plugin-ssr.com/pageContext-anywhere
import { inject } from 'vue';
const key = Symbol();
function usePageContext() {
const pageContext = inject(key);
return pageContext;
}
function setPageContext(app, pageContext) {
app.provide(key, pageContext);
}
export { usePageContext };
export { setPageContext };