{# ================================================================================ Track Single Page Template (Kida-Native) ================================================================================ Pillar page-style layout for learning tracks with: - Left sidebar: Other tracks + progress - Center: Track content (pillar page style) - Right sidebar: TOC from all track sections KIDA FEATURES USED: - {% let %} for template-scoped variables - Optional chaining (?.) for null-safe access - Null coalescing (??) for smart defaults - {% def %} for reusable section components - {% while %} for progress indicator (Kida 2.0!) USAGE: Set `template: tracks/single.html` in frontmatter Or set `type: track` to auto-select this template ================================================================================ #} {% extends "base.html" %} {% from 'partials/navigation-components.html' import toc %} {# ============================================================================= PROGRESS INDICATOR COMPONENT (uses {% while %} - Kida 2.0!) Renders a visual step indicator for track progress. Demonstrates: {% while %} with step-by-step rendering ============================================================================= #} {% def track_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 = 'track-progress__step' %} {% if is_complete %}{% let step_class = step_class ~ ' track-progress__step--complete' %}{% end %} {% if is_current %}{% let step_class = step_class ~ ' track-progress__step--current' %}{% end %}
{% if is_complete %}✓{% else %}{{ step }}{% end %}
{# Connector line between steps (except after last) #} {% if step < total_steps %}
{% end %} {% let step = step + 1 %} {% end %}
Step {{ current_step }} of {{ total_steps }}
{% end %} {# ============================================================================= TRACK SECTION COMPONENT ============================================================================= #} {% def track_section_block(item_page, index, is_last) %} {% let section_prefix = "s" ~ index ~ "-" %} {% let item_title = item_page?.title ?? 'Section' %} {% let item_desc = item_page?.description ?? '' %} {% let item_html = item_page?.html_content %} {% let item_content = item_page?.content ?? '' %} {% let item_href = item_page?.href ?? '#' %}
{# Section Header #}
{{ index }}

{{ item_title }}

{% if item_desc %}

{{ item_desc }}

{% end %}
{# Section Content (headings demoted + IDs prefixed for uniqueness) #} {# resolve_links_for_embedding: relative links -> absolute so they work when embedded #}
{% if item_html %} {{ item_html | resolve_links_for_embedding(item_page) | demote_headings | prefix_heading_ids(section_prefix) | safe }} {% elif item_content %} {{ item_content | resolve_links_for_embedding(item_page) | demote_headings | prefix_heading_ids(section_prefix) | safe }} {% else %}

Content Unavailable

This page has no content available.

View Full Page: {{ item_title }} →

{% end %}
{# Track Complete Badge (only after final section) #} {% if is_last %}
✓ Track Complete
{% end %}
{% end %} {# ============================================================================= MAIN TEMPLATE ============================================================================= #} {% block content %} {# Template-scoped variables #} {% let track_id = params?.track_id ?? page?.slug ?? '' %} {% let tracks_data = site?.data?.tracks ?? {} %} {% let track = tracks_data[track_id] if track_id and track_id in tracks_data else none %} {% let track_items = track?.items ?? [] %} {% let track_title = track?.title ?? page?.title ?? 'Track' %} {% let track_desc = track?.description ?? page?.description ?? '' %} {% let page_toc_items = page?.toc_items ?? [] %} {# PRE-COMPUTE all track item pages ONCE (used by sidebar + content + TOC) #} {% let track_item_pages = {} %} {% for item_slug in track_items %} {% let item_page = get_page(item_slug) %} {% if item_page %} {% let track_item_pages = track_item_pages | merge({item_slug: item_page}) %} {% end %} {% end %} {# Three-column pillar page layout #}
{# Left Sidebar: Track Navigation + Progress #} {# Main Content: Pillar Page Style #}
{# Track Header #} {# Main Page Content (Introduction) #} {% if content %}
{{ content | safe }}
{% end %} {# Render All Track Pages Sequentially (Pillar Page Content) #} {% if track and track_items | length > 0 %}
{% for item_slug in track_items %} {# Use pre-computed page (O(1) lookup instead of get_page call) #} {% let item_page = track_item_pages[item_slug] if item_slug in track_item_pages else none %} {% if item_page %} {{ track_section_block(item_page, loop.index, loop.last) }} {% else %} {# Missing Page Warning #}

Section {{ loop.index }}: Page Not Found

Could not find page: {{ item_slug }}

{% end %} {% end %}
{% elif not track %}

Track Not Found

Could not find a track definition with ID {{ track_id }} in site/data/tracks.yaml.


Please ensure the page slug matches the track key, or set track_id in frontmatter.

{% end %}
{# Right Sidebar: TOC from all track sections #} {% if track and track_items | length > 0 %} {% let combined_toc_items = combine_track_toc(track_items) %} {% if combined_toc_items %} {% end %} {% elif page_toc_items | length > 0 %} {# Fallback to page TOC if no track sections #} {% end %}
{# Mobile sidebar toggle button #} {# Mobile sidebar overlay #} {% end %}