$site.pages 怎么迁移 #549
Answered
by
Mister-Hope
zhouxinyong
asked this question in
Q&A
-
我在迁移theme 到V2版本时,usePagesData的返回值也并不和$site.pages一样。 文档里也没有具体的迁移说明。原来的$site.pages该用什么方式拿到呢 |
Beta Was this translation helpful? Give feedback.
Answered by
Mister-Hope
Dec 7, 2021
Replies: 2 comments 5 replies
-
因为可扩展性的考虑移除了,你不应该试图在客户端侧获取全部的页面对象。 另外你可以使用 routeMeta 去向路由注入一些必要的页面元信息。 你可以关注一下 vuepress-theme-hope,想实现的东西里面都应该有类似地实现。 |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
Mister-Hope
-
由于特殊需要我们确实需要得到所有页面的路径,有什么办法吗?急,谢谢,之前是用: <script>
export default {
computed: {
commands() {
return this.$site.pages
.filter(p => p.path.indexOf('/book/commands/') >= 0)
.sort((a,b) => (a.title > b.title) ? 1 : ((b.title > a.title) ? -1 : 0));
}
}
}
</script> |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
因为可扩展性的考虑移除了,你不应该试图在客户端侧获取全部的页面对象。
另外你可以使用 routeMeta 去向路由注入一些必要的页面元信息。
你可以关注一下 vuepress-theme-hope,想实现的东西里面都应该有类似地实现。