Skip to content

Commit

Permalink
feat: expose params at top level in useData()
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Mar 7, 2023
1 parent a4ac055 commit 66f94fd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/reference/runtime-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ interface VitePressData<T = any> {
page: Ref<PageData>
theme: Ref<T> // themeConfig from .vitepress/config.js
frontmatter: Ref<PageData['frontmatter']>
params: Ref<PageData['params']>
title: Ref<string>
description: Ref<string>
lang: Ref<string>
Expand Down
2 changes: 2 additions & 0 deletions src/client/app/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export interface VitePressData<T = any> {
page: Ref<PageData>
theme: Ref<T>
frontmatter: Ref<PageData['frontmatter']>
params: Ref<PageData['params']>
title: Ref<string>
description: Ref<string>
lang: Ref<string>
Expand Down Expand Up @@ -56,6 +57,7 @@ export function initData(route: Route): VitePressData {
theme: computed(() => site.value.themeConfig),
page: computed(() => route.data),
frontmatter: computed(() => route.data.frontmatter),
params: computed(() => route.data.params),
lang: computed(() => site.value.lang),
dir: computed(() => site.value.dir),
localeIndex: computed(() => site.value.localeIndex || 'root'),
Expand Down

0 comments on commit 66f94fd

Please sign in to comment.