【发布时间】:2021-05-28 00:27:34
【问题描述】:
对于如何在对象上执行 Nuxt Content where() 有点问题。我的意思是考虑以下网址:
www.mysite.com/blog/tag/tag-slug-here
在此页面上,我需要按该标签 slug 过滤所有文章。现在我的 .md 结构如下:
---
layout: documentation
title: Post Title
date: 2016-06-14T15:24:30.719Z
date_updated: ''
tags:
- retainer
- clients
---
...
现在我确实注意到了以下几点:
为了过滤对象和数组,您需要启用nestedProperties,请参阅configuration。
所以在我的 nuxt 配置中我添加了:
content: {
nestedProperties: ['tags']
},
然而这似乎也不起作用。
我的搜索代码:
const articles = await $content()
.where({ tags: params.slug })
.only(['title', 'description', 'thumbnail', 'slug', 'author', 'date'])
.sortBy('date', 'desc')
.limit(5)
.skip((route.query.page || 1) * 5)
.fetch()
我不确定我是否误解了文档或搜索,但如果有人有任何很棒的想法!
【问题讨论】:
标签: nuxt.js nuxt-content