Files
2026-11-14 17:05:01 +00:00

136 lines
5.5 KiB
HTML

{% extends "base.html" %}
{% block title %}{% if page == 'tag' %}Tag: {{ tag_name }} · {{ site_title }}{% elif page == 'category' %}Category: {{ category_name }} · {{ site_title }}{% elif page == 'archive' %}{{ parse_date(month ~ '-01') }} · {{ site_title }}{% else %}{{ site_title }}{% endif %}{% endblock %}
{% block meta_description %}{% if page == 'tag' %}Posts tagged “{{ tag_name }}” on {{ site_title }}.{% elif page == 'category' %}Posts in {{ category_name }} on {{ site_title }}.{% else %}{{ meta_description or site_tagline }}{% endif %}{% endblock %}
{% block head %}
{% if pagination and pagination.has_prev %}<link rel="prev" href="{{ pagination.prev_url }}">{% endif %}
{% if pagination and pagination.has_next %}<link rel="next" href="{{ pagination.next_url }}">{% endif %}
{% if page == 'tag' %}
<link rel="alternate" type="application/atom+xml" title="Tag: {{ tag_name }}"
href="{{ url_for('public.tag_feed', slug=tag_slug) }}">
{% endif %}
{% endblock %}
{% block content %}
{% if page == "category" %}
<h1 class="page-heading">Category: {{ category_name }}</h1>
{% elif page == "tag" %}
<h1 class="page-heading">Tag: {{ tag_name }}</h1>
{% elif page == "archive" %}
<h1 class="page-heading">{{ parse_date(month ~ '-01') }}</h1>
{% else %}
<h1 class="page-heading">Latest Posts</h1>
{% endif %}
<div class="content-area">
<section class="posts">
{% if posts %}
<div class="posts-grid">
{% for p in posts %}
<article class="post-card">
<h2>
<a href="{{ url_for('public.post', slug=p.slug) }}">{{ p.title }}</a>
</h2>
<div class="post-meta">
<span><strong>{{ parse_date(p.created_at) }}</strong></span>
<span>by {{ p.author }}</span>
</div>
{% if p.excerpt %}
<div class="post-excerpt">
{{ p.excerpt|replace("\n", "\n\n")|safe }}
</div>
{% endif %}
<div class="post-footer">
<div class="post-tax">
{% if p.category %}<span class="term">{{ p.category }}</span> &middot; {% endif %}
{% for t in p.tags|tag_list %}
<a class="term" href="{{ url_for('public.tag', slug=t.slug) }}">{{ t.name }}</a>
{% endfor %}
</div>
<a class="read-more" href="{{ url_for('public.post', slug=p.slug) }}">Read more &rarr;</a>
</div>
</article>
{% endfor %}
</div>
{% include "_pagination.html" %}
{% else %}
<p class="empty-state">No posts yet. Sign in to the admin area to add one.</p>
{% endif %}
</section>
<aside class="sidebar">
{# Link tree managed from /admin/links. Rendered only once at least one
link exists, so the panel never appears empty. #}
{% if sidebar.links %}
<div class="widget">
<h2 class="widget-title">Links</h2>
<ul>
{% for link in sidebar.links %}
<li>
{% if link.url.startswith('http') %}
<a href="{{ link.url }}" target="_blank" rel="noopener noreferrer">{{ link.label }}</a>
{% else %}
<a href="{{ link.url }}">{{ link.label }}</a>
{% endif %}
</li>
{% endfor %}
</ul>
</div>
{% endif %}
<div class="widget">
<h2 class="widget-title">Search</h2>
<form class="search-form" method="get" action="{{ url_for('public.search') }}">
<input type="search" name="q" placeholder="Search posts…" value="{{ query if query else '' }}" aria-label="Search">
<button type="submit">Search</button>
</form>
</div>
<div class="widget">
<h2 class="widget-title">Recent Posts</h2>
<ul>
{% for p in sidebar.recent %}
<li><a href="{{ url_for('public.post', slug=p.slug) }}">{{ p.title }}</a></li>
{% else %}
<li><span>No recent posts.</span></li>
{% endfor %}
</ul>
</div>
<div class="widget">
<h2 class="widget-title">Archives</h2>
<ul>
{# One link per month from a GROUP BY query, so pagination can't hide
older months the way deriving this from the current page's posts did. #}
{% for row in sidebar.months %}
<li><a href="{{ url_for('public.archive', month=row.month) }}">{{ parse_date(row.month ~ '-01') }}</a></li>
{% else %}
<li><span>No archives yet.</span></li>
{% endfor %}
</ul>
</div>
<div class="widget">
<h2 class="widget-title">Categories</h2>
<ul>
{% for slug, name in category_map.items() %}
<li><a href="{{ url_for('public.category', slug=slug) }}">{{ name }}</a></li>
{% endfor %}
</ul>
</div>
<div class="widget">
<h2 class="widget-title">Tags</h2>
<div class="tag-cloud">
{% for t in sidebar.tags %}
<a class="term" href="{{ url_for('public.tag', slug=t.slug) }}">{{ t.name }} <small>{{ t.count }}</small></a>
{% else %}
<span class="field-hint">No tags yet.</span>
{% endfor %}
</div>
{% if sidebar.tags %}<p class="field-hint"><a href="{{ url_for('public.tags') }}">All tags &rarr;</a></p>{% endif %}
</div>
</aside>
</div>
{% endblock %}