Added category view for blog posts
This commit is contained in:
@ -18,6 +18,16 @@ def blog_index(page):
|
||||
pagination = Pagination(page, BLOG_POSTS_PER_PAGE, len(all_posts))
|
||||
return render_template('blog/index.html', pagination=pagination, posts=posts)
|
||||
|
||||
@cache.memoize(600)
|
||||
def blog_category(category, page):
|
||||
posts = get_blog_posts()
|
||||
category_posts = [(slug, post) for (slug, post) in posts if post['category'] and category in post['category']]
|
||||
posts = get_for_page(category_posts, page, BLOG_POSTS_PER_PAGE)
|
||||
if not posts and page != 1:
|
||||
abort(404)
|
||||
pagination = Pagination(page, BLOG_POSTS_PER_PAGE, len(category_posts))
|
||||
return render_template('blog/category.html', pagination=pagination, posts=posts, category=category)
|
||||
|
||||
@cache.memoize(600)
|
||||
def blog_post(slug):
|
||||
# try to render that blog post.. throws 404 if it does not exist
|
||||
|
Reference in New Issue
Block a user