Skip to content

Fetching all pages and data #72

Answered by yzx9
ricardobalk asked this question in Q&A
Mar 11, 2021 · 2 comments · 12 replies
Discussion options

You must be logged in to vote

TLDR: import { usePagesData } from "@vuepress/client"

I checked the following code to confirm that we are still provide $site on template:

https://github.com/vuepress/vuepress-next/blob/67118e8d9e57088e68076c631b1bfb58a6d0a730/packages/%40vuepress/client/src/app.ts#L129-L170

However, $site.pages no longer exists:

https://github.com/vuepress/vuepress-next/blob/67118e8d9e57088e68076c631b1bfb58a6d0a730/packages/%40vuepress/shared/src/types/site.ts#L7-L36

So, use hook usePagesData exported from client:

import { usePagesData } from "@vuepress/client"

Also a good idea to inject pages global computed:

// composable/usePosts.ts

import { inject } from "vue"
import { usePagesData } from "@vuepress…

Replies: 2 comments 12 replies

Comment options

You must be logged in to vote
9 replies
@yzx9
Comment options

@ricardobalk
Comment options

@yzx9
Comment options

@ricardobalk
Comment options

@yzx9
Comment options

Answer selected by ricardobalk
Comment options

You must be logged in to vote
3 replies
@yzx9
Comment options

@ricardobalk
Comment options

@meteorlxy
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants