feat: clean output directory on build
This commit is contained in:
parent
71e541aa5e
commit
8793284bd6
2 changed files with 10 additions and 4 deletions
|
@ -1,3 +1,4 @@
|
|||
import shutil
|
||||
from datetime import date
|
||||
from pathlib import Path
|
||||
|
||||
|
@ -50,9 +51,7 @@ class ZonaBuilder:
|
|||
if path.name.endswith(".md") and not path.is_relative_to(
|
||||
layout.root / "content" / "static"
|
||||
):
|
||||
logger.debug(
|
||||
f"Parsing {path.name} as Markdown document."
|
||||
)
|
||||
logger.debug(f"Parsing {path.name}.")
|
||||
item.metadata, item.content = parse_metadata(path)
|
||||
if (
|
||||
item.metadata.draft
|
||||
|
@ -140,6 +139,13 @@ class ZonaBuilder:
|
|||
util.copy_static_file(item.source, dst)
|
||||
|
||||
def build(self):
|
||||
# clean output if applicable
|
||||
if (
|
||||
self.config.build.clean_output_dir
|
||||
and self.layout.output.is_dir()
|
||||
):
|
||||
logger.debug("Removing stale output...")
|
||||
shutil.rmtree(self.layout.output)
|
||||
logger.debug("Discovering...")
|
||||
self._discover()
|
||||
logger.debug("Building...")
|
||||
|
|
|
@ -54,7 +54,7 @@ class MarkdownConfig:
|
|||
|
||||
@dataclass
|
||||
class BuildConfig:
|
||||
# clean_output_dir: bool = True
|
||||
clean_output_dir: bool = True
|
||||
include_drafts: bool = False
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue