{% extends "base.html" %} {# ================================================================================ Tutorial Single Page Template (Kida-Native) ================================================================================ Individual tutorial page optimized for step-by-step learning. KIDA FEATURES USED: - {% let %} for template-scoped variables - Optional chaining (?.) for null-safe access - Null coalescing (??) for smart defaults - {% def %} for reusable card components USAGE: Set `type: tutorial` in frontmatter or use cascade from section ================================================================================ #} {% from 'partials/navigation-components.html' import breadcrumbs, page_navigation %} {# Scroll-synced step progress (mirrors track pattern) #} {% def tutorial_progress_indicator(total_steps, current_step=1) %}
{% let step = 1 %} {% while step <= total_steps %} {% let is_complete = step < current_step %} {% let is_current = step == current_step %} {% let step_class = 'tutorial-progress__step' %} {% if is_complete %}{% let step_class = step_class ~ ' tutorial-progress__step--complete' %}{% end %} {% if is_current %}{% let step_class = step_class ~ ' tutorial-progress__step--current' %}{% end %}
{% if is_complete %}✓{% else %}{{ step }}{% end %}
{% if step < total_steps %}
{% end %} {% let step = step + 1 %} {% end %}
Step {{ current_step }} of {{ total_steps }}
{% end %} {# ============================================================================= RELATED TUTORIAL CARD ============================================================================= #} {% def related_tutorial_card(tutorial) %} {% let tut_meta = tutorial?.metadata ?? {} %} {% let tut_title = tutorial?.title ?? 'Tutorial' %} {% let tut_href = tutorial?.href ?? '#' %} {% let tut_icon = tut_meta?.icon ?? 'book' %} {% let tut_desc = tut_meta?.description ?? '' %} {% let tut_difficulty = tut_meta?.difficulty ?? '' %}
{{ tut_icon }}

{{ tut_title }}

{% if tut_desc %}

{{ tut_desc | truncate(100) }}

{% end %} {% if tut_difficulty %} {{ tut_difficulty | capitalize }} {% end %}
{% end %} {# ============================================================================= MAIN TEMPLATE ============================================================================= #} {% block content %} {# Template-scoped variables #} {% let page_title = page?.title ?? 'Tutorial' %} {% let page_date = page?.date %} {% let page_tags = page?.tags ?? [] %} {% let css_class = params?.css_class ?? '' %} {# Tutorial metadata #} {% let tut_icon = params?.icon ?? '' %} {% let tut_desc = params?.description ?? '' %} {% let tut_difficulty = params?.difficulty ?? '' %} {% let tut_time = params?.time ?? params?.duration ?? '' %} {% let tut_prereqs = params?.prerequisites ?? [] %} {% let tut_objectives = params?.learning_objectives ?? params?.objectives ?? [] %} {% let tut_next_steps = params?.next_steps ?? [] %} {% let tut_further_reading = params?.further_reading ?? [] %} {% let toc_items_list = toc_items ?? [] %} {% let tutorial_step_count = toc_items_list | length %} {% let tutorial_id = page?.slug ?? page?._path ?? '' %}
{% include 'partials/page-hero.html' %}
{# Tutorial Icon #} {% if tut_icon %}
{{ tut_icon }}
{% end %} {# Tutorial Metadata Bar #}
{# Difficulty #} {% if tut_difficulty %} {{ tut_difficulty | capitalize }} {% end %} {# Time Estimate #} {% if tut_time %} {{ icon('clock', size=16) }} {{ tut_time }} {% end %} {# Last Updated #} {% if page_date %} {{ icon('calendar', size=16) }} Updated {{ page_date | time_ago }} {% end %}
{# Scroll-driven progress — updated by tutorials.js #} {% if tutorial_step_count >= 2 %}
{{ tutorial_progress_indicator(tutorial_step_count, 1) }}
{% end %} {# Prerequisites #} {% if tut_prereqs | length > 0 %}

{{ t('tutorial.prerequisites', default='Prerequisites') }}

    {% for prereq in tut_prereqs %}
  • {% if prereq is string %} {% let prereq_page = doc(prereq, site?.indexes?.crossref) if site?.indexes?.crossref else none %} {% if prereq_page %} {{ prereq_page.title }} {% else %} {% let prereq_ref = ref(prereq, site?.indexes?.crossref) if site?.indexes?.crossref else none %} {% if prereq_ref and ' {% end %}
{% end %} {# What You'll Learn #} {% if tut_objectives | length > 0 %}

{{ t('tutorial.what_you_will_learn', default="What you'll learn") }}

    {% for objective in tut_objectives %}
  • {{ objective }}
  • {% end %}
{% end %}
{# Main Tutorial Content #}
{{ content | safe }}
{# What's Next / Further Reading #} {% if tut_next_steps | length > 0 or tut_further_reading | length > 0 %}
{% if tut_next_steps | length > 0 %}

{{ t('tutorial.whats_next', default="What's Next?") }}

    {% for step in tut_next_steps %}
  • {{ step }}
  • {% end %}
{% end %} {% if tut_further_reading | length > 0 %}

{{ t('tutorial.further_reading', default='Further Reading') }}

    {% for resource in tut_further_reading %}
  • {{ resource }}
  • {% end %}
{% end %}
{% end %}
{# Right Sidebar: TOC + scroll-synced step nav #} {% if toc %} {% end %}
{# Prominent Prev/Next Navigation #}
{{ page_navigation(page) }}
{# Related Tutorials #} {% if page_tags | length > 0 %} {% let related = page?.related_posts ?? [] %} {% let related_tutorials = related[:3] %} {% if related_tutorials | length > 0 %} {% end %} {% end %} {% end %}