{% comment %} Renders an article card for a given blog with settings to either show the image or not. Accepts: - blog: {Object} Blog object - article: {Object} Article object - media_aspect_ratio: {String} The setting changes the aspect ratio of the article image, if shown - media_height: {String} The setting changes the height of the article image. Overrides media_aspect_ratio. - show_image: {String} The setting either show the article image or not. If it's not included it will show the image by default - show_date: {String} The setting either show the article date or not. If it's not included it will not show the image by default - show_author: {String} The setting either show the article author or not. If it's not included it will not show the author by default - show_badge: {String} The setting either show the blog badge or not. - lazy_load: {Boolean} Image should be lazy loaded. Default: true (optional) Usage: {% render 'article-card' blog: blog, article: article, show_image: section.settings.show_image %} {% endcomment %} {%- if article and article != empty -%} {%- liquid assign ratio = 1 if media_aspect_ratio != null assign ratio = media_aspect_ratio endif -%}
{% comment %}
{% endcomment %}
{%- if show_image == true and article.image -%}
{% comment %}theme-check-disable ImgLazyLoading{% endcomment %} {{ article.image.src.alt | escape }} {% comment %}theme-check-enable ImgLazyLoading{% endcomment %}
{%- endif -%}

{{ article.title | truncate: 50 | escape }}

{%- if show_date -%} {{ article.published_at | time_tag: format: 'date' }} {%- endif -%} {%- if show_author -%} {{ article.author }} {%- endif -%}
{%- if show_excerpt -%} {%- if article.excerpt.size > 0 or article.content.size > 0 -%}

{%- if article.excerpt.size > 0 -%} {{ article.excerpt | strip_html | truncatewords: 30 }} {%- else -%} {{ article.content | strip_html | truncatewords: 30 }} {%- endif -%}

{%- endif -%}
{%- if article.comments_count > 0 and blog.comments_enabled? -%} {{ 'blogs.article.comments' | t: count: article.comments_count }} {%- endif -%}
{%- endif -%}
{%- if show_badge -%}
{{ 'blogs.article.blog' | t }}
{%- endif -%}

{{ article.title | truncate: 50 | escape }}

{%- if show_date -%} {{ article.published_at | time_tag: format: 'date' }} {%- endif -%} {%- if show_author -%} {{ article.author }} {%- endif -%}
{%- if show_excerpt -%} {%- if article.excerpt.size > 0 or article.content.size > 0 -%}

{%- if article.excerpt.size > 0 -%} {{ article.excerpt | strip_html | truncatewords: 30 }} {%- else -%} {{ article.content | strip_html | truncatewords: 30 }} {%- endif -%}

{%- endif -%}
{%- if article.comments_count > 0 and blog.comments_enabled? -%} {{ 'blogs.article.comments' | t: count: article.comments_count }} {%- endif -%}
{%- endif -%}
{%- if show_badge -%}
{{ 'blogs.article.blog' | t }}
{%- endif -%}
{%- endif -%}