1
Fork 0

Show child sections as children

This commit is contained in:
Jake Howard 2023-09-15 18:11:06 +01:00
parent d247f39d0b
commit 4497904ce2
Signed by: jake
GPG key ID: 57AFB45680EDD477
5 changed files with 33 additions and 1 deletions

6
content/list/index.md Normal file
View file

@ -0,0 +1,6 @@
---
tags:
- tag1
- list
---
# List page

5
content/list/item-1.md Normal file
View file

@ -0,0 +1,5 @@
---
tags:
- item
---
# Item 1

5
content/list/item-2.md Normal file
View file

@ -0,0 +1,5 @@
---
tags:
- item
---
# Item 2

View file

@ -0,0 +1,5 @@
---
tags:
- item
---
# Item 3

View file

@ -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):