{#- chirp-ui: Breadcrumbs component
Navigation trail. Items: list of {label, href?}. Last item (current) has no href.
Usage:
{% from "chirpui/breadcrumbs.html" import breadcrumbs %}
breadcrumbs([
{"label": "Home", "href": "/"},
{"label": "Docs", "href": "/docs"},
{"label": "Getting Started"}
])
-#}
{% def breadcrumb_item(item, current=false) %}
{% if item.get("href") %}
{{ item.label | default("") }}
{% else %}
{{ item.label | default("") }}
{% end %}
{% end %}
{% def breadcrumbs(items, cls="", overflow="", max_items=4) %}
{% set count = items | length %}
{% set collapse = overflow == "collapse" and count > max_items and count > 2 %}
{% set tail_count = (max_items - 2) if max_items > 3 else 1 %}
{% set tail_start = count - tail_count %}
{% end %}