commit d83639937580815dbae36357b962753509d3d1bd
parent 71b67ef710e93c5d1be31f5c293556e77d869ce0
Author: Oscar Benedito <oscar@oscarbenedito.com>
Date:   Thu, 25 Mar 2021 11:26:36 +0100

Add page number to HTML lists

Diffstat:
Mgensite.py | 4++++
Mlayouts/list.html | 2+-
2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/gensite.py b/gensite.py @@ -260,6 +260,7 @@ def make_lists(posts, dst, l_html, l_html_item, l_feed, l_feed_item, **params): # make HTML lists ipp = 5 # items per page params['content'] = '' + title = params['title'] if dst != 'blog/': # blog feed appears on all pages already params['extraheader'] = '<link rel="alternate" type="application/atom+xml" ' \ 'title="{}" href="/{}index.xml"/>'.format(params['feed_title'], dst) @@ -282,6 +283,9 @@ def make_lists(posts, dst, l_html, l_html_item, l_feed, l_feed_item, **params): elif page > 1: params.pop('next_url') + if page != 1: + params['title'] = '{} (page {} of {})'.format(title, page, ((len(posts)-1)//ipp) + 1) + fwrite(curr_dst, render(l_html, **params)) log('I', 'list => /{}', curr_dst) diff --git a/layouts/list.html b/layouts/list.html @@ -1,6 +1,6 @@ <main class="list h-feed"> <header> - <h1>{{ title }}</h1> + <h1>{{ title }}{{ _if page }} (page {{ page }}){{ _fi }}</h1> {{ intro }} </header>