import jinja2 def is_list_page(page) -> bool: if not page.parent: return False return page.parent.children[0] == page def children(page): if not is_list_page(page): return [] return page.parent.children[1:] @jinja2.pass_context def get_page(context, slug): nav = context["nav"] for page in nav.pages: if page.file.src_uri == slug: return page return None def on_env(env, config, files): env.filters["is_list_page"] = is_list_page env.filters["children"] = children env.globals["get_page"] = get_page