Files
KantSites/templates/blocks/post-list.html.twig
T
kantarciandClaude Fable 5.2 b08862b139 Back up unsaved editor work locally, structure the settings, fix archive accessibility
- The editor keeps unsaved changes in the browser and offers them
  after a crash, a closed tab or an expired session. No timed save on
  the server: every save is a full revision.
- The save status stays visible in narrow windows.
- Settings get a sticky section bar, two folded groups and a save bar
  that stays in view.
- The admin post list fetches terms and images once, not per post.
- Archive post titles are second-level headings, the archive head
  keeps full text contrast, the skip link sits above a sticky header,
  a linked image without alternative text names its link.
- The editor check starts through the dev router like the others.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-10 13:01:23 +01:00

51 lines
3.5 KiB
Twig

{# Posts are supplied by the controller, never read from stored content. #}
{% if posts is empty %}
{# Auf der öffentlichen Seite bleibt die Stelle leer: eine Website ohne Blog soll nirgends
von Beiträgen reden. Im Editor steht der Hinweis, sonst sucht jemand den Fehler. #}
{% if editing|default(false) %}<p class="post-empty">Hier erscheinen die Beiträge, sobald welche veröffentlicht sind.</p>{% endif %}
{% else %}
{% set art = layout|default('karten') %}
<ul class="post-list post-list-{{ art }}">
{% for post in posts %}
<li class="post-card">
{% if post.image and art != 'kompakt' %}
<a class="post-image" href="{{ post.href }}" tabindex="-1" aria-hidden="true">
<img src="{{ post.image.variants|last.src }}" alt="" width="{{ post.image.variants|last.width }}" height="{{ post.image.variants|last.height }}" loading="lazy" decoding="async"
srcset="{% for source in post.image.variants %}{{ source.src }} {{ source.width }}w{% if not loop.last %}, {% endif %}{% endfor %}" sizes="(max-width: 650px) 100vw, 380px">
{# Der Hinweis liegt über dem Bild und erscheint beim Zeigen. Für Vorlesesoftware ist
er nichts Neues - der Titel darunter ist derselbe Verweis -, deshalb ausgeblendet. #}
<span class="post-view" aria-hidden="true">{{ 'Ansehen'|kant_t }}</span>
</a>
{% endif %}
<div class="post-body">
{# Im Archiv folgt die Liste direkt auf die Hauptüberschrift, dort ist ein Beitrag eine
Überschrift zweiter Ebene. In einer Seite steht sie unter einer Abschnittsüberschrift. #}
<h{{ headingLevel|default(3) }}><a href="{{ post.href }}">{{ post.title }}</a></h{{ headingLevel|default(3) }}>
{% if (showMeta ?? true) and (post.publishedAt or post.author) %}
<p class="post-meta">
{% if post.publishedAt %}<time datetime="{{ post.publishedAt|date('Y-m-d') }}">{{ post.publishedAt|date('d.m.Y') }}</time>{% endif %}
{% if post.author %}<span>{{ 'von'|kant_t }} {{ post.author }}</span>{% endif %}
</p>
{% endif %}
{% if (showExcerpt ?? true) and post.excerpt %}<p class="post-excerpt">{{ post.excerpt }}</p>{% endif %}
{# Ein Element, das aussieht wie ein Knopf, muss eines sein. Vorher stand hier eine
reine Beschriftung: sichtbar, aber nicht anklickbar. Der Titel steckt für
Vorlesesoftware mit drin, damit "Weiterlesen" nicht zwölfmal gleich heißt. #}
{% if art == 'wechsel' %}<a class="post-more" href="{{ post.href }}">{{ 'Weiterlesen'|kant_t }}<span class="visually-hidden">: {{ post.title }}</span></a>{% endif %}
{% if (showTerms ?? true) and post.terms.category is not empty %}
<p class="post-terms">{% for term in post.terms.category %}<a href="{{ term.href }}">{{ term.name }}</a>{% endfor %}</p>
{% endif %}
</div>
</li>
{% endfor %}
</ul>
{% endif %}
{% if pages|default(1) > 1 %}
{# Dieselbe Blätterleiste wie im Archiv: eine Liste, die mehr hat als sie zeigt, sagt es. #}
<nav class="post-pager" aria-label="{{ 'Weitere Beiträge'|kant_t }}">
{% if page > 1 %}<a rel="prev" href="?seite={{ page - 1 }}">{{ 'Neuere'|kant_t }}</a>{% endif %}
<span>{{ 'Seite %d von %d'|kant_t|format(page, pages) }}{% if total %} · {{ total }} {{ 'Beiträge'|kant_t }}{% endif %}</span>
{% if page < pages %}<a rel="next" href="?seite={{ page + 1 }}">{{ 'Ältere'|kant_t }}</a>{% endif %}
</nav>
{% endif %}