我无法检索包含 nuxt 内容的上一篇和下一篇文章。
在我的 slug 页面中,我有以下代码:
async asyncData({ $content, params }) {
const article = await $content('onstep', params.slug).fetch();
const [prev, next] = await $content('onstep')
.only(['title', 'slug', 'order'])
.sortBy('order', 'desc')
.surround(params.slug)
.fetch();
return {
article,
prev,
next
};
},
但是 prev 和 next 返回 null,我不明白的另一件事是
.surround(params.slug)
为什么用params.slug???
如果我使用邮递员来http://localhost:3000/_content/onstep?only=title&only=slug&only=order
获取我的文章列表,在我的例子中,我使用一个名为 order 的标签来排序应该如何查看内容。
在我的项目中我需要使用trailingSlash
to true
,但是如果我没有 console.log params.slugtrailingSlash
有什么建议么?