refactor builder
This commit is contained in:
parent
8fe55bf3f4
commit
42a8b51914
7 changed files with 168 additions and 117 deletions
|
@ -1,4 +1,17 @@
|
|||
from dataclasses import dataclass, field
|
||||
from dacite import from_dict
|
||||
import yaml
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def find_config(start: Path | None = None) -> Path | None:
|
||||
current = (start or Path.cwd()).resolve()
|
||||
|
||||
for parent in [current, *current.parents]:
|
||||
candidate = parent / "zona.yml"
|
||||
if candidate.is_file():
|
||||
return candidate
|
||||
return None
|
||||
|
||||
|
||||
@dataclass
|
||||
|
@ -23,6 +36,14 @@ class ZonaConfig:
|
|||
title: str = "Zona Blog"
|
||||
base_url: str = "https://example.com"
|
||||
language: str = "en"
|
||||
# list of globs relative to content that should be ignored
|
||||
ignore: list[str] = field(default_factory=lambda: [".env", ".git"])
|
||||
markdown: MarkdownConfig = field(default_factory=MarkdownConfig)
|
||||
theme: ThemeConfig = field(default_factory=ThemeConfig)
|
||||
build: BuildConfig = field(default_factory=BuildConfig)
|
||||
|
||||
@classmethod
|
||||
def from_file(cls, path: Path) -> "ZonaConfig":
|
||||
with open(path, "r") as f:
|
||||
raw = yaml.safe_load(f)
|
||||
return from_dict(data_class=cls, data=raw)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue