84 lines
2.8 KiB
Plaintext
84 lines
2.8 KiB
Plaintext
{% doc %}
|
|
Article card used on the blog index and on related articles.
|
|
|
|
@param {article} article - Article to render
|
|
@param {boolean} [show_excerpt] - Shows the excerpt and read-more label
|
|
@param {boolean} [show_author] - Shows the author next to the date
|
|
@param {boolean} [eager] - Loads the image immediately
|
|
@param {string} [heading_tag] - Heading element, h2 or h3
|
|
|
|
@example
|
|
{% render 'blog-card', article: article, show_excerpt: true, show_author: true %}
|
|
{% enddoc %}
|
|
|
|
{% liquid
|
|
if heading_tag == blank
|
|
assign heading_tag = 'h2'
|
|
endif
|
|
|
|
if eager
|
|
assign image_loading = 'eager'
|
|
else
|
|
assign image_loading = 'lazy'
|
|
endif
|
|
|
|
assign image_alt = ''
|
|
if article.image != blank
|
|
if article.image.alt != blank
|
|
assign image_alt = article.image.alt
|
|
else
|
|
assign image_alt = article.title
|
|
endif
|
|
endif
|
|
|
|
assign excerpt = article.excerpt_or_content | strip_html | truncate: 180
|
|
assign published = article.published_at | date: '%B %d, %Y'
|
|
%}
|
|
|
|
<article class="min-w-0" aria-labelledby="Article-{{ article.id }}">
|
|
<a class="group flex flex-col text-inherit no-underline" href="{{ article.url }}">
|
|
<div class="overflow-hidden rounded-[18px] bg-[#f3f3f3]">
|
|
{% if article.image != blank %}
|
|
{{
|
|
article.image
|
|
| image_url: width: 1200
|
|
| image_tag:
|
|
loading: image_loading,
|
|
widths: '414, 600, 828, 1200',
|
|
sizes: '(max-width: 767px) 100vw, (max-width: 1024px) 50vw, 33vw',
|
|
alt: image_alt,
|
|
class: 'aspect-[3/2] w-full object-cover transition duration-500 ease-out group-hover:scale-105'
|
|
}}
|
|
{% else %}
|
|
<div class="aspect-[3/2] w-full"></div>
|
|
{% endif %}
|
|
</div>
|
|
|
|
<div class="flex flex-col pt-[13.5px]">
|
|
<{{ heading_tag }}
|
|
id="Article-{{ article.id }}"
|
|
class="m-0 text-[22px] font-light leading-[1.27] tracking-[0.6px] text-[#1a1b18]"
|
|
>
|
|
{{- article.title | escape -}}
|
|
</{{ heading_tag }}>
|
|
|
|
<p class="m-0 mt-[6px] text-[9px] font-normal uppercase leading-none tracking-[1.17px] text-[#212326]/75">
|
|
<time datetime="{{ article.published_at | date: '%Y-%m-%d' }}">{{ published }}</time>
|
|
{% if show_author and article.author != blank %}
|
|
<span class="px-[6px]" aria-hidden="true">·</span>
|
|
<span>{{ article.author | escape }}</span>
|
|
{% endif %}
|
|
</p>
|
|
|
|
{% if show_excerpt and excerpt != blank %}
|
|
<p class="mb-[12.6px] mt-[13.5px] line-clamp-3 text-[12.6px] font-normal leading-[21px] text-[#212326]/75">
|
|
{{ excerpt | escape }}
|
|
</p>
|
|
<span class="text-[12.6px] font-normal leading-[1.89] text-[#1a1b18]">
|
|
{{- 'blog.read_more' | t -}}
|
|
</span>
|
|
{% endif %}
|
|
</div>
|
|
</a>
|
|
</article>
|