我希望KeystoneJS博客仅显示发布日期等于或大于今天的帖子。我猜那是在那儿的过滤器设置中发生的:
view.on('init', function (next) {
var q = keystone.list('Post').paginate({
page: req.query.page || 1,
perPage: 9,
maxPages: 10,
filters: {
state: 'published',
},
})
.sort('-publishedDate')
.populate('author categories')
...
必须有一种在某处设置publishedDate <= Date.now
的方法,但我看不到...
找到了:
var today = new Date();
view.on('init', function (next) {
var q = keystone.list('Post').paginate({
page: req.query.page || 1,
perPage: 3,
maxPages: 3,
filters: {
state: 'published',
publishedDate: {
$lte: today,
},
},
})
...