{# ================================================================================ Tag Components (Kida-Native) ================================================================================ Tag display and tag cloud widgets. Components: - tag_list(tags, small, linkable): Styled tag badges - popular_tags_widget(limit): Tag cloud widget ================================================================================ #} {# ============================================================================= TAG LINK HELPER Creates a tag link with consistent styling. ============================================================================= #} {% def tag_link(tag, css_class='tag') %} {{ tag }} {% end %} {# ============================================================================= TAG LIST COMPONENT Displays tags as styled badges, optionally linkable. ============================================================================= #} {% def tag_list(tags, small=false, linkable=true) %} {% let safe_tags = tags ?? [] %} {% let max_display = (theme?.max_tags_display or 0) | int %} {% let display_tags = safe_tags[:max_display] if max_display > 0 else safe_tags %} {% let tag_count = safe_tags | length %}
{% for tag in display_tags %} {% if tag %} {% if linkable %} {{ tag_link(tag) }} {% else %} {{ tag }} {% end %} {% end %} {% end %} {% if max_display > 0 and tag_count > max_display %} +{{ tag_count - max_display }} more {% end %}
{% end %} {# ============================================================================= POPULAR TAGS WIDGET Displays a tag cloud widget with most frequently used tags. ============================================================================= #} {% def popular_tags_widget(limit=none) %} {% let tag_limit = limit ?? theme?.popular_tags_count ?? 10 %} {% let top_tags = popular_tags(limit=tag_limit) ?? [] %} {% if top_tags | length > 0 %} {% end %} {% end %}