diff options
author | Jeffrey Tse <jeffreytse.mail@gmail.com> | 2023-08-26 16:28:58 +0800 |
---|---|---|
committer | Jeffrey Tse <jeffreytse.mail@gmail.com> | 2023-08-26 18:27:56 +0800 |
commit | 2d389272f1f0efc01f2a958f17e1ed73578d5917 (patch) | |
tree | cf23ac38ce026598afbd493c7e02c6ac76b8d815 /_includes/views/pagination-item.html | |
parent | bb1e308bef725f7633909ff494940cfbb7a3f74b (diff) |
feat: rich excerpt with image support (#125)
Diffstat (limited to '_includes/views/pagination-item.html')
-rw-r--r-- | _includes/views/pagination-item.html | 35 |
1 files changed, 29 insertions, 6 deletions
diff --git a/_includes/views/pagination-item.html b/_includes/views/pagination-item.html index fff6541..791fcda 100644 --- a/_includes/views/pagination-item.html +++ b/_includes/views/pagination-item.html @@ -4,11 +4,29 @@ {% assign lang = post.lang %} {%- include functions.html func='get_reading_time' -%} {% assign reading_time = return %} + {%- include functions.html func='get_article_excerpt' -%} {% assign excerpt = return %} {%- assign post_url = post.url | relative_url -%} -<li class="{{ post_item_class }}"> +{%- assign name = 'excerpt.image_width' -%} +{%- include functions.html func='get_value' -%} +{%- assign image_width = return | default: '38.2%' -%} + +{%- assign name = 'excerpt.image_height' -%} +{%- include functions.html func='get_value' -%} +{%- assign image_height = return | default: '160px' -%} + +{%- assign name = 'excerpt.default_image' -%} +{%- include functions.html func='get_value' -%} +{%- assign default_image = return -%} + +{%- assign post_image = post.banner.image + | default: post.banner + | default: default_image + | default: '/assets/images/default-image.jpeg' -%} + +<li class="post-item {{ post_item_class }}"> <h2 class="post-title"> <a class="post-link" href="{{ post_url }}"> {{ post.title | escape }} @@ -22,11 +40,16 @@ {%- endif -%} <span class="post-reading-time left-vsplit"><i class="fa fa-clock-o"></i> {{ reading_time }}</span> </div> - <a class="post-excerpt" href="{{ post_url }}"> - <p> - {{ excerpt }} <span class="read_more">Read More</span> - </p> - </a> + <div class="post-excerpt"> + {%- if post_image -%} + <a class="post-image" href="{{ post_url }}" style="flex: 0 1 {{ image_width }}"> + <div style="background-image: url({{ post_image | relative_url }}); height: {{ image_height }}"></div> + </a> + {%- endif -%} + <a class="post-text" href="{{ post_url }}"> + <p>{{ excerpt }} <span class="read_more">Read More</span></p> + </a> + </div> <div class="post-tags"> {%- for tag in post.tags -%} <a class="post-tag" href="{{ '/tags.html ' | relative_url }}#{{tag}}">#{{tag}}</a> |