diff --git a/omicron/ssg/output/article.py b/omicron/ssg/output/article.py index 648181a..5870412 100644 --- a/omicron/ssg/output/article.py +++ b/omicron/ssg/output/article.py @@ -27,6 +27,7 @@ class Article(Content): meta.get("updated", None), set(meta["tags"]) if "tags" in meta else None, meta.get("summary", None), + meta.get("draft", False), ) self.title: str = meta["title"] diff --git a/omicron/ssg/output/content.py b/omicron/ssg/output/content.py index 02a8414..55cfef2 100644 --- a/omicron/ssg/output/content.py +++ b/omicron/ssg/output/content.py @@ -28,6 +28,7 @@ class Content(Output): updated: date | None = None, tags: set[str] | None = None, summary: str | None = None, + draft: bool = False, ): super().__init__(site, Content.build_path(section, slug)) if tags is None: @@ -42,6 +43,7 @@ class Content(Output): self.updated = updated self.tags: set[str] = tags self.summary: str | None = summary + self.draft: bool = draft @staticmethod def build_path(section: str, slug: str) -> Path: diff --git a/omicron/ssg/site.py b/omicron/ssg/site.py index e7f600b..de63e7e 100644 --- a/omicron/ssg/site.py +++ b/omicron/ssg/site.py @@ -34,6 +34,7 @@ class ConfigError(RuntimeError): class Site: def __init__(self, site: Path, drafts: bool = False): self.site_path = site.resolve() + self.drafts = drafts self.content: list[Content] = [] self.directories: list[Directory] = [] self.other_outputs: list[Output] = [] @@ -178,6 +179,9 @@ class Site: for file in content_path.rglob("*"): if file.is_file() and is_content(file): content = create_content(self, file) + if content.draft and not self.drafts: + log.debug("Skipping draft content %s", file) + continue self.add_by_path(content) self.add_by_section(content) self.add_by_tag(content)