【发布时间】:2012-10-21 18:59:44
【问题描述】:
我正在使用 Node.js 和 Express 开发一个 webapp。在这个应用程序中,我管理 JSON 数据流以使用 Tumblr API 创建博客阅读器。
我把路线写成:
app.get('/blog', function(req, res) {
var Tumblr = require('tumblr').Tumblr
, keys = require('./keystore');
// Instancing Tumblr object to connect with a certain blog.
var blog = new Tumblr('myblog.tumblr.com', keys.tumblrConsumerSecret);
// Using Tumblr API to retrieve posts from a remote blog.
// For more info about methods and parameters to use, read the
// documentation for Tumblr's API v2.
blog.posts({offset: 0, limit: 5}, function(err, tumblr) {
if (err) {
res.send('Error page... I suppose!');
}
else {
res.render('blog',
{
blog: tumblr.posts
});
}
});
});
还有blog.jade:
each post in blog
h2 #{post.title}
.justified
!= post.body
现在,我想为阅读器添加编号页面导航功能(作为服务器端)。
page 1: posts from 1 to 5
page 2: posts from 6 to 10
(etc...)
我该怎么办?
最好的问候,维。
【问题讨论】:
标签: json node.js pagination express tumblr