summaryrefslogtreecommitdiff
path: root/_includes
diff options
context:
space:
mode:
authorJeffrey Tse <jeffreytse.mail@gmail.com>2023-08-26 16:28:58 +0800
committerJeffrey Tse <jeffreytse.mail@gmail.com>2023-08-26 18:27:56 +0800
commit2d389272f1f0efc01f2a958f17e1ed73578d5917 (patch)
treecf23ac38ce026598afbd493c7e02c6ac76b8d815 /_includes
parentbb1e308bef725f7633909ff494940cfbb7a3f74b (diff)
feat: rich excerpt with image support (#125)
Diffstat (limited to '_includes')
-rw-r--r--_includes/functions/get_article_excerpt.html2
-rw-r--r--_includes/views/pagination-item.html35
-rw-r--r--_includes/views/pagination.html6
3 files changed, 35 insertions, 8 deletions
diff --git a/_includes/functions/get_article_excerpt.html b/_includes/functions/get_article_excerpt.html
index 2868b8d..b34a13f 100644
--- a/_includes/functions/get_article_excerpt.html
+++ b/_includes/functions/get_article_excerpt.html
@@ -12,7 +12,7 @@
{% assign excerpt_size = include.params.excerpt_size %}
{% else %}
{% assign excerpt_size = excerpt_size
- | default: site.excerpt_size
+ | default: site.excerpt.text_size
| default: 350 %}
{% endif %}
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>
diff --git a/_includes/views/pagination.html b/_includes/views/pagination.html
index 014df85..a9de074 100644
--- a/_includes/views/pagination.html
+++ b/_includes/views/pagination.html
@@ -4,10 +4,14 @@
{%- assign paginator = site -%}
{%- endif -%}
+{%- assign name = 'excerpt.image_style' -%}
+{%- include functions.html func='get_value' default='z' -%}
+{%- assign image_style = return | append: '-image-style' -%}
+
{%- if paginator.posts.size > 0 -%}
<div class="pagination">
<!-- Post list links -->
- <ul class="post-list">
+ <ul class="post-list {{ image_style }}">
<!-- Top list item -->
{%- if paginator == site or paginator.page == 1 -%}
{%- assign post_item_class = "top-post" -%}