began implementation
This commit is contained in:
parent
a05f63bf26
commit
53f09b72db
6 changed files with 87 additions and 2 deletions
23
src/zona/builder.py
Normal file
23
src/zona/builder.py
Normal file
|
@ -0,0 +1,23 @@
|
|||
from zona.models import Item
|
||||
from pathlib import Path
|
||||
import frontmatter
|
||||
import os
|
||||
|
||||
|
||||
def discover(root: str, out_dir: str) -> list[Item]:
|
||||
root_path = Path(root)
|
||||
required_dirs = {"content", "static", "templates"}
|
||||
found_dirs = {p.name for p in root_path.iterdir() if p.is_dir()}
|
||||
missing = required_dirs - found_dirs
|
||||
assert not missing, f"Missing required directories: {', '.join(missing)}"
|
||||
|
||||
items: list[Item] = []
|
||||
|
||||
for subdir in required_dirs:
|
||||
base = root_path / subdir
|
||||
for path in base.rglob("*"):
|
||||
if path.is_file():
|
||||
print(f"{subdir}: {path.relative_to(root_path)}")
|
||||
# TODO: build Item here
|
||||
# items.append(...)
|
||||
return items
|
23
src/zona/cli.py
Normal file
23
src/zona/cli.py
Normal file
|
@ -0,0 +1,23 @@
|
|||
import typer
|
||||
from zona import builder
|
||||
|
||||
app = typer.Typer()
|
||||
|
||||
|
||||
@app.command()
|
||||
def discover(in_dir: str | None = None):
|
||||
out_dir = ""
|
||||
if in_dir is None:
|
||||
in_dir = "."
|
||||
_ = builder.discover(in_dir, out_dir)
|
||||
|
||||
|
||||
@app.command()
|
||||
def init():
|
||||
# init will populate the current directory with
|
||||
# the required folders and their default values
|
||||
print("Init logic here...")
|
||||
|
||||
|
||||
def main():
|
||||
app()
|
19
src/zona/models.py
Normal file
19
src/zona/models.py
Normal file
|
@ -0,0 +1,19 @@
|
|||
from pathlib import Path
|
||||
from datetime import datetime
|
||||
from dataclasses import dataclass
|
||||
|
||||
|
||||
@dataclass
|
||||
class Metadata:
|
||||
title: str
|
||||
date: datetime
|
||||
description: str
|
||||
# add more options later...
|
||||
|
||||
|
||||
@dataclass
|
||||
class Item:
|
||||
source: Path
|
||||
destination: Path
|
||||
url: str # relative to site root
|
||||
metadata: Metadata | None # frontmatter
|
0
src/zona/parser.py
Normal file
0
src/zona/parser.py
Normal file
Loading…
Add table
Add a link
Reference in a new issue