Show child sections as children
This commit is contained in:
parent
d247f39d0b
commit
4497904ce2
5 changed files with 33 additions and 1 deletions
6
content/list/index.md
Normal file
6
content/list/index.md
Normal file
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
tags:
|
||||
- tag1
|
||||
- list
|
||||
---
|
||||
# List page
|
5
content/list/item-1.md
Normal file
5
content/list/item-1.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
tags:
|
||||
- item
|
||||
---
|
||||
# Item 1
|
5
content/list/item-2.md
Normal file
5
content/list/item-2.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
tags:
|
||||
- item
|
||||
---
|
||||
# Item 2
|
5
content/list/item-3/index.md
Normal file
5
content/list/item-3/index.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
tags:
|
||||
- item
|
||||
---
|
||||
# Item 3
|
13
hooks/nav.py
13
hooks/nav.py
|
@ -10,7 +10,18 @@ def is_list_page(page) -> bool:
|
|||
def children(page):
|
||||
if not is_list_page(page):
|
||||
return []
|
||||
return page.parent.children[1:]
|
||||
|
||||
page_children = []
|
||||
|
||||
for child in page.parent.children[1:]:
|
||||
if child.is_page:
|
||||
page_children.append(child)
|
||||
|
||||
# If the child is a section, use its index page as the child
|
||||
if child.is_section:
|
||||
page_children.append(child.children[0])
|
||||
|
||||
return page_children
|
||||
|
||||
@jinja2.pass_context
|
||||
def get_page(context, slug):
|
||||
|
|
Loading…
Reference in a new issue