{# ================================================================================ Article Card Component (Kida-Native) ================================================================================ Rich article preview card with metadata, tags, and optional image. Usage: {{ article_card(post, show_excerpt=true, show_image=false) }} ================================================================================ #} {% from 'partials/components/tags.html' import tag_list %} {% from 'chirpui/badge.html' import badge %} {% from 'chirpui/card.html' import resource_card %} {# ============================================================================= ARTICLE CARD COMPONENT Displays a rich card preview of an article with metadata, tags, and image. ============================================================================= #} {% def article_card(article, show_excerpt=true, show_image=false) %} {% let article_meta = article?.metadata ?? {} %} {% let article_params = article_meta?.params ?? article?.params ?? {} %} {% let article_tags = article?.tags ?? [] %} {% let article_content = article?.content ?? '' %} {% let article_date = article?.date %} {% let article_image = article_meta?.image ?? '' %} {% let article_desc = article_meta?.description ?? '' %} {% let author_slug = article_params?.author ?? article_meta?.author ?? '' %} {% let authors_registry = site?.data?.authors ?? {} %} {% let author_data = authors_registry.get(author_slug, {}) if author_slug else {} %} {% let article_author = author_data?.name ?? article_meta?.author ?? article_params?.author ?? '' %} {% let is_featured = article is featured %} {% let theme_features = theme?.features ?? [] %} {% let article_excerpt = none %} {% if show_excerpt and 'content.excerpts' in theme_features %} {% if article_desc %} {% let article_excerpt = article_desc %} {% elif article_content %} {% let article_excerpt = article_content | strip_html | excerpt(150) %} {% end %} {% end %} {% call resource_card( article.href ?? article._path ?? article.path ?? '#', article.title, description=article_excerpt, top_meta=(article_date | time_ago if article_date else none), cls='chirp-theme-article-card' ~ (' chirp-theme-article-card--featured' if is_featured else ''), link_mode='main' ) %} {% slot badges %} {% if is_featured %} {{ badge('Featured', variant='warning') }} {% end %} {% if article | has_tag('new') %} {{ badge('New', variant='success') }} {% end %} {% end %} {% slot subtitle %} {% if article_author and 'content.author' in theme_features %} {{ article_author }} {% end %} {% if article?.reading_time and 'content.reading_time' in theme_features %} {{ ' ยท ' if article_author and 'content.author' in theme_features else '' }}{{ article.reading_time }} min read {% end %} {% end %} {% if show_image and article_image %} {{ article_image | image_alt }} {% end %} {% if article_tags | length > 0 %} {% slot footer %} {{ tag_list(article_tags, small=true) }} {% end %} {% end %} {% end %}