Skip to content

Commit

Permalink
Fixes crash when page navigation is shown when using dynamic indexes …
Browse files Browse the repository at this point in the history
…while INDEXES_PAGES_MAIN being False.
  • Loading branch information
felixfontein committed Jan 31, 2017
1 parent ff8e04b commit 024899e
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions nikola/nikola.py
Expand Up @@ -2474,7 +2474,10 @@ def generic_index_renderer(self, lang, posts, indexes_title, template_name, cont
# form [num_pages, 1, 2, ..., num_pages - 1] -- we order it
# via a map. This allows to not replicate the logic of
# utils.get_displayed_page_number() here.
temp_map = {page_number - 1: link for page_number, link in zip(displayed_page_numbers, page_links)}
if not kw["indexes_pages_main"] and not kw["indexes_static"]:
temp_map = {page_number: link for page_number, link in zip(displayed_page_numbers, page_links)}
else:
temp_map = {page_number - 1: link for page_number, link in zip(displayed_page_numbers, page_links)}
page_links_context = [temp_map[i] for i in range(num_pages)]
for i, post_list in enumerate(lists):
context = context_source.copy()
Expand Down Expand Up @@ -2526,7 +2529,10 @@ def generic_index_renderer(self, lang, posts, indexes_title, template_name, cont
context['show_index_page_navigation'] = kw['show_index_page_navigation']
if kw['show_index_page_navigation']:
context['page_links'] = page_links_context
context['current_page'] = ipages_i - 1
if not kw["indexes_pages_main"] and not kw["indexes_static"]:
context['current_page'] = ipages_i
else:
context['current_page'] = ipages_i - 1
context['prev_next_links_reversed'] = kw['indexes_static']
context["permalink"] = page_links[i]
output_name = os.path.join(kw['output_folder'], page_path(i, ipages_i, num_pages, False))
Expand Down

0 comments on commit 024899e

Please sign in to comment.