Detect whether page is list page
This commit is contained in:
parent
9800836c52
commit
f3bb6b0b3c
4 changed files with 20 additions and 1 deletions
1
content/nested/sibling.md
Normal file
1
content/nested/sibling.md
Normal file
|
@ -0,0 +1 @@
|
||||||
|
# Sibling
|
8
hooks/nav.py
Normal file
8
hooks/nav.py
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
def is_list_page(page) -> bool:
|
||||||
|
if not page.parent:
|
||||||
|
return False
|
||||||
|
|
||||||
|
return page.parent.children[0] == page
|
||||||
|
|
||||||
|
def on_env(env, config, files):
|
||||||
|
env.filters["is_list_page"] = is_list_page
|
|
@ -5,3 +5,6 @@ strict: true
|
||||||
theme:
|
theme:
|
||||||
name: null
|
name: null
|
||||||
custom_dir: theme
|
custom_dir: theme
|
||||||
|
|
||||||
|
hooks:
|
||||||
|
- hooks/nav.py
|
||||||
|
|
|
@ -1,3 +1,10 @@
|
||||||
{{ page.content }}
|
{{ page.content }}
|
||||||
|
|
||||||
{{ nav }}
|
Nav: {{ nav }}
|
||||||
|
|
||||||
|
Parent: {{ page.parent }}
|
||||||
|
Section: {{ page.is_section }}
|
||||||
|
|
||||||
|
Is lits page: {{ page|is_list_page }}
|
||||||
|
|
||||||
|
Children: {{ page.children }}
|
||||||
|
|
Loading…
Reference in a new issue