Reliably get page children for list pages
This commit is contained in:
parent
f3bb6b0b3c
commit
c8eb405165
2 changed files with 7 additions and 1 deletions
|
@ -4,5 +4,11 @@ def is_list_page(page) -> bool:
|
||||||
|
|
||||||
return page.parent.children[0] == page
|
return page.parent.children[0] == page
|
||||||
|
|
||||||
|
def children(page):
|
||||||
|
if not is_list_page(page):
|
||||||
|
return []
|
||||||
|
return page.parent.children[1:]
|
||||||
|
|
||||||
def on_env(env, config, files):
|
def on_env(env, config, files):
|
||||||
env.filters["is_list_page"] = is_list_page
|
env.filters["is_list_page"] = is_list_page
|
||||||
|
env.filters["children"] = children
|
||||||
|
|
|
@ -7,4 +7,4 @@ Section: {{ page.is_section }}
|
||||||
|
|
||||||
Is lits page: {{ page|is_list_page }}
|
Is lits page: {{ page|is_list_page }}
|
||||||
|
|
||||||
Children: {{ page.children }}
|
Children: {{ page|children }}
|
||||||
|
|
Loading…
Reference in a new issue