diff --git a/scripts/blog.py b/scripts/blog.py index 6ca49af..df2b009 100644 --- a/scripts/blog.py +++ b/scripts/blog.py @@ -282,7 +282,9 @@ def summarize(doc): def render_index(docs, dest_top): docs = sorted(docs.values(), key=lambda x: x[1]['date'], reverse=True) - for off in range(0, len(docs), BLOG_INDEX_PAGE_SIZE): + index_ranges = range(0, len(docs), BLOG_INDEX_PAGE_SIZE) + + for off in index_ranges: page = docs[off: off + BLOG_INDEX_PAGE_SIZE] posts = [ @@ -297,8 +299,17 @@ def render_index(docs, dest_top): for (doc, front_matter, out_path) in page ] + prev_index_num = None + next_index_num = off // BLOG_INDEX_PAGE_SIZE + 1 + if off > 0: + prev_index_num = off // BLOG_INDEX_PAGE_SIZE - 1 + if next_index_num >= len(index_ranges): + next_index_num = None + result = BLOG_INDEX_TEMPLATE.render( posts=posts, + prev_index_num=prev_index_num, + next_index_num=next_index_num, ) if off == 0: diff --git a/static/blog_index.tmpl.html b/static/blog_index.tmpl.html index df6a1a3..c34c0ec 100644 --- a/static/blog_index.tmpl.html +++ b/static/blog_index.tmpl.html @@ -48,5 +48,18 @@ {% endfor %} +