{# ================================================================================ Action Bar Component (Kida-Native) ================================================================================ PATTERN: POPOVER - Share dropdown and metadata panel use native [popover] - Browser handles: show/hide, light dismiss, escape key, top layer - JS handles: Copy actions, AI share functionality KIDA FEATURES USED: - {% let %} for template-scoped variables - Optional chaining (?.) for null-safe access - Null coalescing (??) for smart defaults - {% def %} for reusable helper USAGE: {% include 'partials/action-bar.html' %} ================================================================================ #} {# ============================================================================= HELPER: Get page URL with fallback chain ============================================================================= #} {% def get_page_url(page) -%} {{ (page?.href ?? page?._path ?? '/') | trim }} {%- end %} {# ============================================================================= BREADCRUMB ITEM HELPER ============================================================================= #} {% def breadcrumb_item(item, has_metadata=false) %} {% let item_title = item?.title ?? 'Page' %} {% let item_href = item?.href ?? '#' %} {% let is_current = item?.is_current ?? false %} {% if is_current %} {{ item_title | truncate(20, true, '…') }} {% if has_metadata %} {% end %} {% else %} {{ item_title | truncate(28, true, '…') }} {% end %} {% end %} {# ============================================================================= MAIN COMPONENT ============================================================================= #} {% if page %} {# Template-scoped variables #} {% 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 %} {# Breadcrumbs - assign outside cache for variable access #} {% let breadcrumb_items = get_breadcrumbs(page) ?? [] %} {% let params = params ?? {} %} {% let has_metadata = (params?.author ?? none) or (page?.date ?? none) or (page?.content ?? none) or (params?.lastmod ?? none) %} {% let theme_features = theme?.features ?? [] %}
{# Main Action Bar #}
{# Left: Breadcrumbs #} {# Right: Actions #}
{# LLM Share Button #}
{# Quick Actions #} {{ icon('external', size=16) }} {{ t('share.open_llm_text', default='Open LLM text') }} {% include 'partials/connect-to-ide.html' %}
{# AI Assistant Links #}
{{ t('share.with_ai', default='Share with AI') }}
{% let ai_platforms = [ {'id': 'claude', 'name': 'Claude', 'icon': 'ai-claude', 'url': 'https://claude.ai/new?q='}, {'id': 'chatgpt', 'name': 'ChatGPT', 'icon': 'ai-chatgpt', 'url': 'https://chatgpt.com/?q='}, {'id': 'gemini', 'name': 'Gemini', 'icon': 'ai-gemini', 'url': 'https://gemini.google.com/app?q='}, {'id': 'copilot', 'name': 'Copilot', 'icon': 'ai-copilot', 'url': 'https://copilot.microsoft.com/?q='} ] %} {% for ai in ai_platforms %} {{ icon(ai.icon, size=16) }} {{ t('share.ask_' ~ ai.id, default='Ask ' ~ ai.name) }} {% end %}
{# Expandable Metadata Panel #} {% if has_metadata %} {% end %}
{% end %}