You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
vitepress/lib/app/composables/pageData.js

22 lines
410 B

5 years ago
import { inject } from 'vue'
/**
* @typedef {import('vue').Ref<import('src').PageData>} PageDataRef
*/
/**
* @type {import('vue').InjectionKey<PageDataRef>}
*/
5 years ago
export const pageDataSymbol = Symbol()
/**
* @returns {PageDataRef}
*/
5 years ago
export function usePageData() {
const data = inject(pageDataSymbol)
5 years ago
if (!data) {
throw new Error('usePageData() is called without provider.')
}
return data
5 years ago
}