const { Article } = require(‘../../model/acticle‘);
const pagination = require(‘mongoose-sex-page‘);
module.exports = async(req, res) => {
const page = req.query.page || 1;
// 标识当前访问的是用户管理页面
req.app.locals.currentLink = ‘article‘;
let articles = await pagination(Article).find().page(page).size(2).display(3).populate(‘author‘).exec();
// res.send(articles);
// 查询所有文章数据
res.render(‘admin/article‘, {
articles: articles
});
}
<ul class="pagination">
{{if articles.page > 1}}
<li>
<a href="/admin/article?page={{articles.page - 1 }}">
<span>«</span>
</a>
</li>
{{/if}} {{each articles.display}}
<li><a href="/admin/article?page={{$value}}">{{$value}}</a></li>
{{/each}} {{if articles.page
< articles.pages}} <li>
<a href="/admin/article?page={{articles.page - 0 + 1}}">
<span>»</span>
</a>
</li>
{{/if}}
</ul>