diff --git a/src/zona/builder.py b/src/zona/builder.py
index 556baa1..ded2363 100644
--- a/src/zona/builder.py
+++ b/src/zona/builder.py
@@ -89,7 +89,9 @@ class ZonaBuilder:
reverse=True,
)
templater = Templater(
- template_dir=self.layout.templates, post_list=post_list
+ config=self.config,
+ template_dir=self.layout.templates,
+ post_list=post_list,
)
self.item_map = {
item.source.resolve(): item for item in self.items
diff --git a/src/zona/config.py b/src/zona/config.py
index ed51f43..c66ee58 100644
--- a/src/zona/config.py
+++ b/src/zona/config.py
@@ -14,6 +14,9 @@ def find_config(start: Path | None = None) -> Path | None:
return None
+SitemapConfig = dict[str, str]
+
+
@dataclass
class BlogConfig:
dir: str = "blog"
@@ -53,6 +56,8 @@ class ZonaConfig:
title: str = "Zona Blog"
base_url: str = "https://example.com"
language: str = "en"
+ # dictionary where key is name, value is url
+ sitemap: SitemapConfig = field(default_factory=lambda: {"Home": "/"})
# list of globs relative to content that should be ignored
ignore: list[str] = field(default_factory=lambda: IGNORELIST)
markdown: MarkdownConfig = field(default_factory=MarkdownConfig)
diff --git a/src/zona/data/templates/footer.md b/src/zona/data/templates/footer.md
index 653482d..e18a549 100644
--- a/src/zona/data/templates/footer.md
+++ b/src/zona/data/templates/footer.md
@@ -1 +1 @@
-The footer content.
+My Markdown footer!
diff --git a/src/zona/data/templates/header.html b/src/zona/data/templates/header.html
new file mode 100644
index 0000000..f058c85
--- /dev/null
+++ b/src/zona/data/templates/header.html
@@ -0,0 +1,5 @@
+
+{% for name, url in site_map.items() %}
+ - {{ name }}
+{% endfor %}
+
diff --git a/src/zona/data/templates/header.md b/src/zona/data/templates/header.md
deleted file mode 100644
index a0e3630..0000000
--- a/src/zona/data/templates/header.md
+++ /dev/null
@@ -1,2 +0,0 @@
-- One
-- Two
diff --git a/src/zona/templates.py b/src/zona/templates.py
index 0147df3..806fcf6 100644
--- a/src/zona/templates.py
+++ b/src/zona/templates.py
@@ -1,6 +1,7 @@
from pathlib import Path
from typing import Literal
from jinja2 import Environment, FileSystemLoader, select_autoescape
+from zona.config import ZonaConfig
from zona.models import Item
from zona.markdown import md_to_html
@@ -26,16 +27,25 @@ def get_footer(template_dir: Path) -> str | None:
# TODO: add next/prev post button logic to posts
# TODO: add a recent posts element that can be included elsewhere?
class Templater:
- def __init__(self, template_dir: Path, post_list: list[Item]):
+ def __init__(
+ self,
+ config: ZonaConfig,
+ template_dir: Path,
+ post_list: list[Item],
+ ):
self.env: Environment = Environment(
loader=FileSystemLoader(template_dir),
autoescape=select_autoescape(["html", "xml"]),
)
+ self.config: ZonaConfig = config
self.template_dir: Path = template_dir
- self.header: str | None = get_header(template_dir)
self.footer: str | None = get_footer(template_dir)
self.post_list: list[Item] = post_list
+ def render_header(self):
+ template = self.env.get_template("header.html")
+ return template.render(site_map=self.config.sitemap)
+
def render_item(self, item: Item, content: str) -> str:
env = self.env
meta = item.metadata
@@ -46,7 +56,7 @@ class Templater:
else meta.template + ".html"
)
header: str | Literal[False] = (
- self.header if self.header and meta.header else False
+ self.render_header() if meta.header else False
)
footer: str | Literal[False] = (
self.footer if self.footer and meta.footer else False