getzola/zola

get_page() fails if a page is marked as draft, not sure how else to check if a page is a draft while building menu

Open

#1,991 opened on Sep 19, 2022

View on GitHub
 (15 comments) (0 reactions) (0 assignees)Rust (1,046 forks)batch import
good first issuehelp wanted

Repository metrics

Stars
 (15,349 stars)
PR merge metrics
 (Avg merge 48d 17h) (4 merged PRs in 30d)

Description

Bug Report

Environment

Zola version: 0.16.0

Expected Behavior

This function is probably working as originally intended, so what I am asking for may actually be a new feature unless there is another way to accomplish this?

Current Behavior

This started with a feature request to not show certain menu items if those pages are marked as draft. https://github.com/Jieiku/abridge/issues/92

I created a solution:

https://github.com/Jieiku/abridge/commit/bca64259827edb25a19c4b910ab28907b0b29d93

but if I set draft = true for about.md then zola no longer builds/serves the site.

Building site...
Checking all internal links with anchors.
> Successfully checked 1 internal link(s) with anchors.
-> Creating 12 pages (2 orphan) and 2 sections
Error: Failed to serve the site
Error: Failed to render section '/home/jieiku/.dev/abridge/content/posts/_index.md'
Error: Reason: Failed to render 'posts.html' (error happened in a parent template)
Error: Reason: Function call 'get_page' failed
Error: Reason: Page `pages/about.md` not found.

Step to reproduce

git clone -b menu-draft-check https://github.com/Jieiku/abridge
cd abridge
zola serve

The site will serve/build if you set draft = false in content/pages/about.md

If there is another way of doing this that I have not figured out then I appologize for the report, I did review the zola and tera documentation first and spent a couple of days thinking about the issue.

Contributor guide