Skip to content

Instantly share code, notes, and snippets.

@andy-williams
Last active August 29, 2015 13:57
Show Gist options
  • Save andy-williams/9589990 to your computer and use it in GitHub Desktop.
Save andy-williams/9589990 to your computer and use it in GitHub Desktop.
Poet - get post page
poet.helpers.getPostPage = function(title) {
var postsPerPage = poet.options.postsPerPage;
var pageCount = poet.helpers.getPageCount();
for(var i=1; i < pageCount; i++) {
var from = (i-1) * postsPerPage;
var to = from + postsPerPage;
var posts = poet.helpers.getPosts(from, to);
if(title in posts) {
return i;
}
}
//not found
return 0;
};
app.locals.getPostPage = poet.helpers.getPostPage;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment