Skip to content

Commit

Permalink
Fix bug where plugin crashes if you specify the same page twice in yo…
Browse files Browse the repository at this point in the history
…ur navigation
  • Loading branch information
timvink committed Oct 4, 2020
1 parent dec3eb3 commit cbc8a4d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion mkdocs_print_site_plugin/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def on_config(self, config, **kwargs):

def on_nav(self, nav, config, files, **kwargs):

# Save the (order of) pages in the navigation
# Save the (order of) pages in the navigation before adding the print page
self.renderer.pages = nav.pages.copy() # nav_pages

# Optionally add the print page to the site navigation
Expand Down
4 changes: 3 additions & 1 deletion mkdocs_print_site_plugin/renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ def write_combined(self):
html += self._toc()

# Update internal anchor links
page_htmls = [fix_internal_links(p.html, p.url) for p in self.pages]
# If you specify the same page in your navigation, it is only rendered once
# Hence the hasattr(p, 'html)
page_htmls = [fix_internal_links(p.html, p.url) for p in self.pages if hasattr(p, 'html')]
html += "".join(page_htmls)

html += "</div>"
Expand Down

0 comments on commit cbc8a4d

Please sign in to comment.