2

I would like my KeystoneJS blog to only display Posts with a Published Date equal or more ancient to Today. I guess that happens in the filter setting there :

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')
...

There must be a way to set a publishedDate <= Date.now somewhere but I can't see it...

UPDATE

Found it :

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,
            },
        },
    })
    ...
BLGV 75
  • 21
  • 2

0 Answers0