{# ================================================================================ Page Hero Macros (Pure Definitions) - Kida-Native v2 ================================================================================ All hero variants as pure macro definitions. No side effects, safe to import. USAGE: {% from 'partials/page-hero/_macros.html' import hero_editorial, hero_element %} {{ hero_editorial(page, params, theme) }} VARIANTS: - hero_editorial: Clean magazine layout (default for single pages) - hero_magazine: Editorial with container/background styling - hero_overview: Section index with page count - hero_classic: Traditional action-bar + header (two-piece layout) - hero_element: Autodoc elements (modules, classes, commands) - hero_section: Autodoc section indexes INTERNAL HELPERS (prefixed with _): - _get_page_url: URL with fallback chain - _share_dropdown: LLM share button with popover (data-driven) - _breadcrumb_eyebrow: Breadcrumbs as eyebrow - _hero_metadata: Unified metadata row (DRY extraction) - _element_badges: DocElement badges (pattern-matched) - _element_stats: DocElement stats KIDA FEATURES USED: - Data-driven loops for AI assistant rendering - {% match %} for element badge dispatching - {% with %} for nil-resilient metadata sections - {% let %} for scoped variable binding - {% capture %} for string building - Pipeline operators (|>) for cleaner filter chains - Optional chaining (?.) and null coalescing (??) For automatic routing based on hero_style, use: {% include 'partials/page-hero.html' %} ================================================================================ #} {% from 'partials/navigation-components.html' import breadcrumbs %} {# ============================================================================= HELPER MACROS (internal) ============================================================================= #} {# Get page URL with fallback chain #} {% def _get_page_url(page) -%} {{ (page?._path ?? page?.href ?? '/') | trim }} {%- end %} {# ============================================================================= AI ASSISTANTS DATA (data-driven configuration) Extracted for maintainability - add new AI assistants here. ============================================================================= #} {% let AI_ASSISTANTS = [ {'id': 'claude', 'name': 'Claude', 'url': 'https://claude.ai/new', 'icon': 'ai-claude'}, {'id': 'chatgpt', 'name': 'ChatGPT', 'url': 'https://chatgpt.com/', 'icon': 'ai-chatgpt'}, {'id': 'gemini', 'name': 'Gemini', 'url': 'https://gemini.google.com/app', 'icon': 'ai-gemini'}, {'id': 'copilot', 'name': 'Copilot', 'url': 'https://copilot.microsoft.com/', 'icon': 'ai-copilot'} ] %} {# ============================================================================= SHARE DROPDOWN MACRO (internal) Renders the LLM share button with popover menu. PATTERN: POPOVER - browser handles show/hide, light dismiss, escape key KIDA FEATURES: - Data-driven AI assistant loop (no repetition) - {% let %} for URL computation - Pipeline operators for clean encoding ============================================================================= #} {% def _share_dropdown(page) %} {% let page_url = canonical_url(_get_page_url(page)) %} {% let llm_txt_url = ensure_trailing_slash(page_url) ~ 'index.txt' %} {% let share_prompt = "Please help me understand this documentation: " ~ llm_txt_url %}
{{ desc }}
{% end %} {% end %} {# Unified Metadata Row (DRY) #} {{ _hero_metadata(page, params, theme) }}{{ desc }}
{% end %} {% end %} {# Unified Metadata Row (DRY) #} {{ _hero_metadata(page, params, theme) }}{{ desc }}
{% end %} {% end %} {# Section Stats - page count with smart pluralization #} {% if total_count > 0 %} {% end %}{{ desc }}
{% end %} {% end %}{{ display_name }}