added metadata parsing

This commit is contained in:
Daniel Fichtinger 2025-06-15 22:07:08 -04:00
parent 8f0e420a8f
commit 729bde2f55
6 changed files with 43 additions and 28 deletions

View file

@ -1,7 +1,17 @@
from zona.models import Item
from zona.models import Item, Metadata
from pathlib import Path
import frontmatter
import os
from dacite import from_dict
def split_metadata(path: Path) -> tuple[Metadata, str]:
post = frontmatter.load(str(path))
meta = post.metadata
metadata = from_dict(
data_class=Metadata,
data=meta,
)
return metadata, post.content
def discover(root: str, out_dir: str) -> list[Item]:
@ -18,6 +28,9 @@ def discover(root: str, out_dir: str) -> list[Item]:
for path in base.rglob("*"):
if path.is_file():
print(f"{subdir}: {path.relative_to(root_path)}")
if path.name.endswith(".md"):
pass
# page = Frontmatter.read_file(path.name)
# TODO: build Item here
# items.append(...)
return items

View file

@ -1,12 +1,12 @@
from pathlib import Path
from datetime import datetime
from datetime import date
from dataclasses import dataclass
@dataclass
class Metadata:
title: str
date: datetime
date: date
description: str
# add more options later...

View file

@ -0,0 +1 @@