{% extends "base.html" %} {# ================================================================================ Tutorial List Template (Kida-Native) ================================================================================ Tutorial section index with difficulty levels, time estimates, and grid layout. 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 card components USAGE: Set `type: tutorial` in section _index.md ================================================================================ #} {% from 'partials/navigation-components.html' import breadcrumbs %} {# ============================================================================= TUTORIAL CARD COMPONENT ============================================================================= #} {% def tutorial_card(tutorial) %} {% let tut_meta = tutorial?.metadata ?? {} %} {% let tut_title = tutorial?.title ?? 'Tutorial' %} {% let tut_href = tutorial?.href ?? tutorial?._path ?? '#' %} {% let tut_icon = tut_meta?.icon ?? 'book' %} {% let tut_desc = tut_meta?.description ?? tutorial?.excerpt ?? '' %} {% let tut_difficulty = tut_meta?.difficulty ?? '' %} {% let tut_time = tut_meta?.time ?? tut_meta?.duration ?? '' %} {% let tut_prereqs = tut_meta?.prerequisites ?? [] %}
{{ tut_icon }}

{{ tut_title }}

{% if tut_desc %}

{{ tut_desc | excerpt_for_card(tut_title) | excerpt(150) }}

{% end %}
{# Difficulty Badge #} {% if tut_difficulty %} {{ tut_difficulty | capitalize }} {% end %} {# Time Estimate #} {% if tut_time %} {{ icon('clock', size=14) }} {{ tut_time }} {% end %} {# Prerequisites #} {% if tut_prereqs | length > 0 %} {{ icon('check-circle', size=14) }} {{ tut_prereqs | length }} prerequisite{{ 's' if tut_prereqs | length != 1 else '' }} {% end %}
Start tutorial →
{% end %} {# ============================================================================= SUBSECTION CARD COMPONENT ============================================================================= #} {% def subsection_card(subsection) %} {% let sub_title = subsection?.title ?? 'Category' %} {% let sub_href = subsection?.href ?? subsection?._path ?? '#' %} {% let sub_desc = subsection?.metadata?.description ?? '' %} {% let sub_pages = subsection?.regular_pages ?? [] %} {% let index_page = subsection?.index_page %} {% let index_path = index_page?._path ?? '' %} {% 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 | excerpt_for_card(sub_title) | excerpt(150) }}

{% end %}
{% if page_count > 0 %} {{ page_count }} tutorial{{ 's' if page_count != 1 else '' }} {% end %}
{% end %} {# ============================================================================= MAIN TEMPLATE ============================================================================= #} {% block content %} {# Template-scoped variables #} {% let section_title = section?.title ?? title ?? 'Tutorials' %} {% let section_desc = section?.metadata?.description ?? description ?? '' %} {% let tutorial_posts = posts ?? [] %} {% let tutorial_subsections = subsections ?? [] %}
{# Action Bar: Breadcrumbs + Share #} {% include 'partials/action-bar.html' %}
{# Tutorial Statistics #} {% if tutorial_posts | length > 0 %} {% let beginner_count = tutorial_posts |> where('metadata.difficulty', 'beginner') |> length %} {% let intermediate_count = tutorial_posts |> where('metadata.difficulty', 'intermediate') |> length %} {% let advanced_count = tutorial_posts |> where('metadata.difficulty', 'advanced') |> length %}
{{ tutorial_posts | length }} {{ 'tutorial' if tutorial_posts | length == 1 else 'tutorials' }}
{% if beginner_count > 0 %}
{{ beginner_count }} beginner
{% end %} {% if intermediate_count > 0 %}
{{ intermediate_count }} intermediate
{% end %} {% if advanced_count > 0 %}
{{ advanced_count }} advanced
{% end %}
{% end %} {# Tutorial Grid #} {% if tutorial_posts | length > 0 or tutorial_subsections | length > 0 %}
{# Subsections (Tutorial Categories) #} {% if tutorial_subsections | length > 0 %}

Categories

{% for subsection in tutorial_subsections %} {{ subsection_card(subsection) }} {% end %}
{% end %} {# Individual Tutorials #} {% if tutorial_posts | length > 0 %}

All Tutorials

{% for tutorial in tutorial_posts %} {{ tutorial_card(tutorial) }} {% end %}
{% end %}
{% else %} {# Empty State #}

No tutorials available yet.

{% end %}
{% end %}