feat: expose params at top level in useData()

pull/2044/head
Evan You 2 years ago
parent a4ac055dbf
commit 66f94fd7a0

@ -16,6 +16,7 @@ interface VitePressData<T = any> {
page: Ref<PageData> page: Ref<PageData>
theme: Ref<T> // themeConfig from .vitepress/config.js theme: Ref<T> // themeConfig from .vitepress/config.js
frontmatter: Ref<PageData['frontmatter']> frontmatter: Ref<PageData['frontmatter']>
params: Ref<PageData['params']>
title: Ref<string> title: Ref<string>
description: Ref<string> description: Ref<string>
lang: Ref<string> lang: Ref<string>

@ -23,6 +23,7 @@ export interface VitePressData<T = any> {
page: Ref<PageData> page: Ref<PageData>
theme: Ref<T> theme: Ref<T>
frontmatter: Ref<PageData['frontmatter']> frontmatter: Ref<PageData['frontmatter']>
params: Ref<PageData['params']>
title: Ref<string> title: Ref<string>
description: Ref<string> description: Ref<string>
lang: Ref<string> lang: Ref<string>
@ -56,6 +57,7 @@ export function initData(route: Route): VitePressData {
theme: computed(() => site.value.themeConfig), theme: computed(() => site.value.themeConfig),
page: computed(() => route.data), page: computed(() => route.data),
frontmatter: computed(() => route.data.frontmatter), frontmatter: computed(() => route.data.frontmatter),
params: computed(() => route.data.params),
lang: computed(() => site.value.lang), lang: computed(() => site.value.lang),
dir: computed(() => site.value.dir), dir: computed(() => site.value.dir),
localeIndex: computed(() => site.value.localeIndex || 'root'), localeIndex: computed(() => site.value.localeIndex || 'root'),

Loading…
Cancel
Save