diff --git a/src/zona/builder.py b/src/zona/builder.py index 446f07d..c53701e 100644 --- a/src/zona/builder.py +++ b/src/zona/builder.py @@ -99,6 +99,13 @@ class ZonaBuilder: else date.min, reverse=True, ) + posts = len(post_list) + for i, item in enumerate(post_list): + prev = post_list[i - 1] if i > 0 else None + next = post_list[i + 1] if i < posts - 2 else None + item.previous = prev + item.next = next + templater = Templater( config=self.config, template_dir=self.layout.templates, diff --git a/src/zona/data/content/static/style.css b/src/zona/data/content/static/style.css index d2cacf0..f02717e 100644 --- a/src/zona/data/content/static/style.css +++ b/src/zona/data/content/static/style.css @@ -31,6 +31,18 @@ header { text-transform: lowercase; } +.post-nav { + font-family: monospace; +} + +.post-nav .symbol { + color: var(--main-bullet-color); +} + +.post-nav a { + margin: 0 2px; +} + .site-logo { color: inherit; font-weight: bold; diff --git a/src/zona/data/templates/page.html b/src/zona/data/templates/page.html index fd3cdb4..0c22f8b 100644 --- a/src/zona/data/templates/page.html +++ b/src/zona/data/templates/page.html @@ -1,18 +1,12 @@ -{% extends "base.html" %} {% block content %} - -{% if metadata.show_title %} -{% include "title.html" %} -{% if metadata.date %} +{% extends "base.html" %} {% block content %} {% if metadata.show_title %} {% +include "title.html" %} {% if metadata.date %}
-{% endif %} +{% endif %} {% endif %} {% if is_post %} {% include "post_nav.html" %} {% endif +%}
-{% endif %}
{{ content | safe }}
{% endblock %} - - - diff --git a/src/zona/data/templates/post_nav.html b/src/zona/data/templates/post_nav.html new file mode 100644 index 0000000..324f110 --- /dev/null +++ b/src/zona/data/templates/post_nav.html @@ -0,0 +1,9 @@ +
+
+ <{% if previous %}prev{% endif %}{% if previous and next %}|{% endif %}{% if next %}next{% endif + %}> +
+
diff --git a/src/zona/metadata.py b/src/zona/metadata.py index 0cd6a8c..98b14cf 100644 --- a/src/zona/metadata.py +++ b/src/zona/metadata.py @@ -18,6 +18,8 @@ class Metadata: date: date description: str | None show_title: bool = True + show_date: bool = True + show_nav: bool = True style: str | None = "/static/style.css" header: bool = True footer: bool = True diff --git a/src/zona/models.py b/src/zona/models.py index 2e7721c..d009476 100644 --- a/src/zona/models.py +++ b/src/zona/models.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from dataclasses import dataclass from enum import Enum from pathlib import Path @@ -21,6 +23,8 @@ class Item: type: ItemType | None = None copy: bool = True post: bool = False + next: Item | None = None + previous: Item | None = None # @dataclass diff --git a/src/zona/templates.py b/src/zona/templates.py index 872762c..fe1e6dd 100644 --- a/src/zona/templates.py +++ b/src/zona/templates.py @@ -3,6 +3,7 @@ from typing import Literal from jinja2 import Environment, FileSystemLoader, select_autoescape +from zona import util from zona.config import ZonaConfig from zona.markdown import md_to_html from zona.models import Item @@ -76,5 +77,10 @@ class Templater: metadata=meta, header=header, footer=footer, + is_post=item.post, + next=util.normalize_url(item.next.url) if item.next else None, + previous=util.normalize_url(item.previous.url) + if item.previous + else None, post_list=self.post_list, )