{% extends "base.html" %}
{% from "chirpui/layout.html" import container %}
{% from "chirpui/resource_index.html" import resource_index %}
{% from "chirpui/rendered_content.html" import rendered_content %}
{% from "chirpui/badge.html" import badge %}
{% from "chirpui/card.html" import resource_card %}
{% from "partials/navigation-components.html" import pagination %}
{% from "partials/taxonomy-pages.html" import count_label, taxonomy_post_feed %}
{% block content %}
{% let page_title = page?.title ?? section?.title ?? title ?? "Archive" %}
{% let page_desc = page?.description ?? section?.description ?? description ?? "Browse published content." %}
{% let archive_posts = posts ?? pages ?? [] %}
{% let archive_sections = subsections ?? [] %}
{% let total_count = total_posts ?? (archive_posts | length) %}
{% let total_pages = (total_pages ?? 1) | int %}
{% let current_page = (current_page ?? 1) | int %}
{% let base_url = base_url ?? section?.href ?? page?.href ?? "/archive/" %}
{% call container(cls="chirp-theme-taxonomy-page") %}
{% call resource_index(
page_title,
page?.href ?? base_url,
subtitle=page_desc,
search_placeholder="Filter archive...",
button_icon="magnifying-glass",
results_title="Archive",
results_subtitle=count_label(total_count, "entry"),
has_results=(archive_posts | length > 0) or (archive_sections | length > 0),
empty_title="No archived content yet",
empty_message="Published content will appear here automatically.",
cls="chirp-theme-taxonomy-index"
) %}
{% if content %}
{% call rendered_content(compact=true) %}{{ content | safe }}{% end %}
{% end %}
{% if archive_posts | length > 0 %}
{{ taxonomy_post_feed(archive_posts, "No archived content yet.") }}
{% elif archive_sections | length > 0 %}
{% for subsection in archive_sections %}
{% let sub_title = subsection?.title ?? subsection?.name ?? "Section" %}
{% let sub_href = subsection?.href ?? "#" %}
{% let sub_desc = subsection?.description ?? subsection?.params?.description ?? none %}
{% let sub_count = subsection?.pages | length if subsection?.pages else 0 %}
{% let sub_icon = subsection?.metadata?.icon ?? "folder" %}
{% call resource_card(sub_href, sub_title, description=sub_desc, cls="chirp-theme-taxonomy-card chirp-theme-taxonomy-card--section") %}
{% slot badges %}
{{ icon(sub_icon, size=18) }}
{% end %}
{% slot footer %}
{{ badge(count_label(sub_count, "page"), variant="muted") }}
{% end %}
{% end %}
{% end %}
{% end %}
{% end %}
{% if total_pages > 1 %}
{{ pagination(current_page, total_pages, base_url) }}
{% end %}
{% end %}
{% end %}