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 datetime import date
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
@ -50,9 +51,7 @@ class ZonaBuilder:
|
||||||
if path.name.endswith(".md") and not path.is_relative_to(
|
if path.name.endswith(".md") and not path.is_relative_to(
|
||||||
layout.root / "content" / "static"
|
layout.root / "content" / "static"
|
||||||
):
|
):
|
||||||
logger.debug(
|
logger.debug(f"Parsing {path.name}.")
|
||||||
f"Parsing {path.name} as Markdown document."
|
|
||||||
)
|
|
||||||
item.metadata, item.content = parse_metadata(path)
|
item.metadata, item.content = parse_metadata(path)
|
||||||
if (
|
if (
|
||||||
item.metadata.draft
|
item.metadata.draft
|
||||||
|
@ -140,6 +139,13 @@ class ZonaBuilder:
|
||||||
util.copy_static_file(item.source, dst)
|
util.copy_static_file(item.source, dst)
|
||||||
|
|
||||||
def build(self):
|
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...")
|
logger.debug("Discovering...")
|
||||||
self._discover()
|
self._discover()
|
||||||
logger.debug("Building...")
|
logger.debug("Building...")
|
||||||
|
|
|
@ -54,7 +54,7 @@ class MarkdownConfig:
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class BuildConfig:
|
class BuildConfig:
|
||||||
# clean_output_dir: bool = True
|
clean_output_dir: bool = True
|
||||||
include_drafts: bool = False
|
include_drafts: bool = False
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue