Last active
August 29, 2015 13:57
-
-
Save andy-williams/9589990 to your computer and use it in GitHub Desktop.
Poet - get post page
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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