def tagged(tag, page=1):
"""Display posts tagged with the given tag.
Args:
tag (str): Tag name.
page (int): Listing page number to show.
"""
posts = (
Post.query
.filter(Post.tags.any(name=tag))
.filter_by(is_published=True, ghost='')
.order_by(Post.timestamp.desc())
.paginate(page, 10, False)
)
try:
return render_theme('blog/tagged.html', posts=posts, tag=tag)
except NotFound:
# Show a 'no posts found' notice instead of a 404 error
return render_theme('blog/tagged.html', tag=tag)
评论列表
文章目录