{% extends "base.html" %} {# ================================================================================ Blog List Template (Kida-Native) ================================================================================ Blog section index with featured posts, excerpts, and pagination. KIDA FEATURES USED: - {% let %} for template-scoped variables - Optional chaining (?.) for null-safe access - Null coalescing (??) for smart defaults - Pipeline operator (|>) for filter chains - {% def %} for reusable post card components - {% match %} for conditional rendering CONTEXT VARIABLES: - section: Section object with blog posts - posts: List of blog post pages (may be paginated) - subsections: Blog categories/archives - total_pages: Total pagination pages - current_page: Current page number NOTE: Uses post.word_count and post.reading_time computed properties instead of filters for better performance (cached on first access). USAGE: Set `type: blog` in section _index.md ================================================================================ #} {% from 'partials/navigation-components.html' import breadcrumbs, pagination %} {% from 'partials/components/tags.html' import tag_list %} {# ============================================================================= POST CARD COMPONENTS ============================================================================= #} {# Featured post card (larger, more prominent) - uses PostView for normalized access #} {% def featured_card(post) %} {% let p = post | post_view %} {% end %} {# Regular post card - uses PostView for normalized access #} {% def post_card(post) %} {% let p = post | post_view %}
{% if p.image %}
{{ p.title }}
{% end %}

{{ p.title }}

{% if p.description %}

{{ p.description | truncate(200) }}

{% end %}
{% if p.author %} {% if p.author_avatar %} {{ p.author }} {% end %} {{ p.author }} {% end %} {% if p.date %} {% end %} {% if p.reading_time > 0 %} {{ p.reading_time }} min read {% end %}
{% if p.tags | length > 0 %}
{{ tag_list(p.tags[:4]) }}
{% end %} Read more →
{% end %} {# Category/subsection card #} {% def category_card(subsection) %} {% let sub_title = subsection?.title ?? 'Category' %} {% let sub_href = subsection?.href ?? '#' %} {% let sub_desc = subsection?.metadata?.description ?? '' %} {% let sub_pages = subsection?.regular_pages ?? [] %} {% let index_page = subsection?.index_page %} {% let index_path = index_page?._path ?? '' %} {# Count non-index pages #} {% let content_pages = sub_pages |> rejectattr('relative_url', 'eq', index_path) |> list %} {% let page_count = content_pages | length %}

{{ sub_title }}

{% if sub_desc %}

{{ sub_desc }}

{% end %} {% if page_count > 0 %}

{{ page_count }} post{{ 's' if page_count != 1 else '' }}

{% end %}
{% end %} {# ============================================================================= MAIN TEMPLATE ============================================================================= #} {# Defensive defaults for pagination #} {% let total_pages = total_pages ?? 1 %} {% let current_page = current_page ?? 1 %} {% let total_posts = total_posts ?? (posts | length if posts else 0) %} {% let base_url = base_url ?? section?.href ?? '/blog/' %} {% block content %}
{# Action Bar: Breadcrumbs + Share #} {% include 'partials/action-bar.html' %}
{# Header #} {% let section_title = section?.title ?? title ?? 'Blog' %} {% let section_desc = section?.metadata?.description ?? description ?? '' %} {% if posts %} {# Featured Posts Section (first page only) #} {% if current_page == 1 %} {% let featured_posts = posts |> where('featured', true) |> take(3) %} {% else %} {% let featured_posts = [] %} {% end %} {% if featured_posts | length > 0 %} {% end %} {# Regular Posts Section #} {% if current_page == 1 %} {% let regular_posts = posts |> where_not('featured', true) %} {% else %} {% let regular_posts = posts %} {% end %} {% if regular_posts | length > 0 %}
{% if featured_posts | length > 0 and current_page == 1 %}

Recent Posts

{% end %}
{% for post in regular_posts %} {{ post_card(post) }} {% export last_regular_post = post %} {% end %}
{% end %} {# Pagination #} {% if total_pages > 1 %} {{ pagination(current_page, total_pages, base_url) }} {% end %} {% elif subsections | length > 0 %} {# Show blog categories/archives if no posts #}

Categories

{% for subsection in subsections %} {{ category_card(subsection) }} {% end %}
{% else %} {# Empty State #}

No blog posts yet. Check back soon!

{% end %}
{% end %}