1
Fork 0

Detect whether page is list page

This commit is contained in:
Jake Howard 2023-09-08 22:10:52 +01:00
parent 9800836c52
commit f3bb6b0b3c
Signed by: jake
GPG Key ID: 57AFB45680EDD477
4 changed files with 20 additions and 1 deletions

View File

@ -0,0 +1 @@
# Sibling

8
hooks/nav.py Normal file
View 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

View File

@ -5,3 +5,6 @@ strict: true
theme:
name: null
custom_dir: theme
hooks:
- hooks/nav.py

View File

@ -1,3 +1,10 @@
{{ page.content }}
{{ nav }}
Nav: {{ nav }}
Parent: {{ page.parent }}
Section: {{ page.is_section }}
Is lits page: {{ page|is_list_page }}
Children: {{ page.children }}