Ensure parent page is actually a page
This commit is contained in:
parent
2b49b04154
commit
b501c34afb
1 changed files with 7 additions and 4 deletions
11
hooks/nav.py
11
hooks/nav.py
|
@ -25,11 +25,14 @@ def children(page):
|
|||
|
||||
def get_parent_page(page):
|
||||
if is_list_page(page) and len(page.parent.children) == 1:
|
||||
parent_section = page.parent.parent
|
||||
if parent_section:
|
||||
return parent_section.children[0]
|
||||
parent = page.parent.parent
|
||||
else:
|
||||
parent = page.parent
|
||||
|
||||
return page.parent
|
||||
if parent is None:
|
||||
return None
|
||||
|
||||
return parent.children[0]
|
||||
|
||||
|
||||
@jinja2.pass_context
|
||||
|
|
Loading…
Reference in a new issue