{% extends "base.html" %}

{#
================================================================================
Generic Post Template (Kida-Native)
================================================================================

Default template for blog posts and articles.

KIDA FEATURES USED:
- {% let %} for template-scoped variables
- Optional chaining (?.) for null-safe access
- Null coalescing (??) for smart defaults
- {% def %} for reusable components

USAGE:
Auto-selected for posts without a specific type
================================================================================
#}

{% from 'partials/navigation-components.html' import breadcrumbs %}
{% from 'partials/components/tags.html' import tag_list %}
{% from 'partials/components/related-posts-simple.html' import related_posts_simple %}

{# =============================================================================
   MAIN TEMPLATE
   ============================================================================= #}

{% block content %}
{# Template-scoped variables #}
{% let page_title = page?.title ?? 'Post' %}
{% let page_tags = page?.tags ?? [] %}
{% let css_class = params?.css_class ?? '' %}

<div class="container">
  <div class="{{ ['page-layout', 'page-with-toc' if toc] | classes }}">
    <article class="post">
      <header class="post-header">
        <h1>{{ page_title }}</h1>
      </header>

      <div class="post-content prose">
        {{ content | safe }}
      </div>

      {% if page_tags | length > 0 %}
      <footer class="post-footer">
        <div class="tags">
          <strong>Tags:</strong>
          {{ tag_list(page_tags) }}
        </div>
      </footer>
      {% end %}
    </article>

    {% if toc %}
    <aside class="page-sidebar">
      <nav class="toc" aria-label="Table of contents">
        <h2 class="toc-title">On This Page</h2>
        <div class="toc-content">
          {{ toc | safe }}
        </div>
      </nav>
    </aside>
    {% end %}
  </div>
</div>

{{ related_posts_simple(page?.related_posts ?? [], 'Related Posts') }}
{% end %}
