28 lines
729 B
TypeScript
28 lines
729 B
TypeScript
import { inject, provide, type InjectionKey } from 'vue'
|
|
import { useConfigStore } from '@/store/configStore'
|
|
|
|
export interface AboutUsPageContext {
|
|
config: ReturnType<typeof useConfigStore>
|
|
}
|
|
|
|
export const ABOUT_US_PAGE_CONTEXT_KEY: InjectionKey<AboutUsPageContext> = Symbol('aboutUsPageContext')
|
|
|
|
export function useAboutUsPage() {
|
|
const config = useConfigStore()
|
|
|
|
const context: AboutUsPageContext = {
|
|
config,
|
|
}
|
|
|
|
provide(ABOUT_US_PAGE_CONTEXT_KEY, context)
|
|
return context
|
|
}
|
|
|
|
export function useAboutUsPageContext() {
|
|
const context = inject(ABOUT_US_PAGE_CONTEXT_KEY)
|
|
if (!context) {
|
|
throw new Error('useAboutUsPageContext must be used within a page that calls useAboutUsPage()')
|
|
}
|
|
return context
|
|
}
|