Add draft content support, excluded from build by default
This commit is contained in:
@@ -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"]
|
||||
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user