feat: ignore frontmatter option

This commit is contained in:
Daniel Fichtinger 2025-07-14 16:11:47 -04:00
parent 27178dc6d8
commit 07152a3746
3 changed files with 9 additions and 15 deletions

View file

@ -317,6 +317,7 @@ available:
| `template` | `str \| none` = `none` | Template to use for this page. Relative to `templates/`, `.html` extension optional. | | `template` | `str \| none` = `none` | Template to use for this page. Relative to `templates/`, `.html` extension optional. |
| `post` | `bool \| none` = `none` | Whether this page is a **post**. `true`/`false` is _absolute_. Leave it unset for automatic detection. | | `post` | `bool \| none` = `none` | Whether this page is a **post**. `true`/`false` is _absolute_. Leave it unset for automatic detection. |
| `draft` | `bool` = `false` | Whether this page is a draft. See [drafts](#drafts) for more. | | `draft` | `bool` = `false` | Whether this page is a draft. See [drafts](#drafts) for more. |
| `ignore` | `bool` = `false` | Whether this page should be ignored in _both_ `final` and `draft` contexts. |
| `math` | `bool` = `true` | Whether the LaTeX extension should be enabled for this page. | | `math` | `bool` = `true` | Whether the LaTeX extension should be enabled for this page. |
**Note**: you can specify the date in any format that can be parsed by **Note**: you can specify the date in any format that can be parsed by

View file

@ -48,14 +48,12 @@ class ZonaBuilder:
destination=destination, destination=destination,
url=str(destination.relative_to(layout.output)), url=str(destination.relative_to(layout.output)),
) )
if path.name.endswith( if path.name.endswith(".md") and not path.is_relative_to(
".md"
) and not path.is_relative_to(
layout.root / "content" / "static" layout.root / "content" / "static"
): ):
logger.debug(f"Parsing {path.name}.") logger.debug(f"Parsing {path.name}.")
item.metadata, item.content = parse_metadata(path) item.metadata, item.content = parse_metadata(path)
if ( if item.metadata.ignore or (
item.metadata.draft item.metadata.draft
and not self.config.build.include_drafts and not self.config.build.include_drafts
): ):
@ -71,13 +69,11 @@ class ZonaBuilder:
item.copy = False item.copy = False
name = destination.stem name = destination.stem
if name == "index": if name == "index":
item.destination = ( item.destination = item.destination.with_suffix(
item.destination.with_suffix(".html") ".html"
) )
else: else:
relative = path.relative_to(base).with_suffix( relative = path.relative_to(base).with_suffix("")
""
)
name = relative.stem name = relative.stem
item.destination = ( item.destination = (
layout.output layout.output
@ -89,9 +85,7 @@ class ZonaBuilder:
layout.output layout.output
) )
item.url = ( item.url = (
"" "" if rel_url == Path(".") else rel_url.as_posix()
if rel_url == Path(".")
else rel_url.as_posix()
) )
items.append(item) items.append(item)
self.items = items self.items = items
@ -117,9 +111,7 @@ class ZonaBuilder:
# write code highlighting stylesheet # write code highlighting stylesheet
if self.config.markdown.syntax_highlighting.enabled: if self.config.markdown.syntax_highlighting.enabled:
pygments_style = zmd.get_style_defs(self.config) pygments_style = zmd.get_style_defs(self.config)
pygments_path = ( pygments_path = self.layout.output / "static" / "pygments.css"
self.layout.output / "static" / "pygments.css"
)
util.ensure_parents(pygments_path) util.ensure_parents(pygments_path)
pygments_path.write_text(pygments_style) pygments_path.write_text(pygments_style)
for item in self.item_map.values(): for item in self.item_map.values():

View file

@ -24,6 +24,7 @@ class Metadata:
template: str | None = None template: str | None = None
post: bool | None = None post: bool | None = None
draft: bool = False draft: bool = False
ignore: bool = False
math: bool = True math: bool = True