Compare commits
2 commits
404e951651
...
c489a6f076
Author | SHA1 | Date | |
---|---|---|---|
c489a6f076 | |||
933210c93b |
8 changed files with 51 additions and 15 deletions
|
@ -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,
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 %}
|
||||
<center>
|
||||
<time class="post-date" datetime="{{ metadata.date | safe }}"
|
||||
>{{ metadata.date | safe}}</time>
|
||||
</center>
|
||||
{% endif %}
|
||||
{% endif %} {% endif %} {% if is_post %} {% include "post_nav.html" %} {% endif
|
||||
%}
|
||||
<hr>
|
||||
{% endif %}
|
||||
|
||||
<article>{{ content | safe }}</article>
|
||||
{% endblock %}
|
||||
|
||||
|
||||
|
||||
|
|
9
src/zona/data/templates/post_nav.html
Normal file
9
src/zona/data/templates/post_nav.html
Normal file
|
@ -0,0 +1,9 @@
|
|||
<div class="post-nav">
|
||||
<center>
|
||||
<span class="symbol"><</span>{% if previous %}<a
|
||||
href="{{ previous.url }}"
|
||||
>prev</a>{% endif %}{% if previous and next %}<span class="symbol"
|
||||
>|</span>{% endif %}{% if next %}<a href="{{ next.url }}">next</a>{% endif
|
||||
%}<span class="symbol">></span>
|
||||
</center>
|
||||
</div>
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -237,9 +237,11 @@ def serve(
|
|||
observer.schedule(
|
||||
event_handler, path=str(root / "content"), recursive=True
|
||||
)
|
||||
templates = root / "templates"
|
||||
if templates.is_dir():
|
||||
observer.schedule(
|
||||
event_handler,
|
||||
path=str(root / "templates"),
|
||||
path=str(templates),
|
||||
recursive=True,
|
||||
)
|
||||
observer.start()
|
||||
|
|
|
@ -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,
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue