diff options
author | Jeffrey Tse <jeffreytse.mail@gmail.com> | 2023-08-21 20:33:58 +0800 |
---|---|---|
committer | Jeffrey Tse <jeffreytse.mail@gmail.com> | 2023-08-23 15:12:07 +0800 |
commit | 30437acaf53524ed97175d513b23d8042f3cf375 (patch) | |
tree | a22d4cc5407cfaf6c95bb19c99974f7d4ffb0ca2 /_includes/views/pagination.html | |
parent | f3d2a6fc15e2889c563459ef86137df275714d2c (diff) |
feat: support to pin articles (#50)
This feature can allow you to top articles via post front meta
property `top`, the value is a number, the smaller the number is,
the higher priority the article has.
Example:
```
title: My Article
top: <number>
```
Diffstat (limited to '_includes/views/pagination.html')
-rw-r--r-- | _includes/views/pagination.html | 48 |
1 files changed, 17 insertions, 31 deletions
diff --git a/_includes/views/pagination.html b/_includes/views/pagination.html index 88be011..014df85 100644 --- a/_includes/views/pagination.html +++ b/_includes/views/pagination.html @@ -8,38 +8,24 @@ <div class="pagination"> <!-- Post list links --> <ul class="post-list"> - {%- for post in paginator.posts -%} - <li> - {%- assign date_format = site.yat.date_format | default: "%b %-d, %Y" -%} - - {% assign article = post.content %} - {% 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 -%} + <!-- Top list item --> + {%- if paginator == site or paginator.page == 1 -%} + {%- assign post_item_class = "top-post" -%} + {%- assign posts = site.posts + | where_exp: "item", "item.top > 0" + | sort: "top" -%} + {%- for post in posts -%} + {%- include views/pagination-item.html -%} + {%- endfor -%} + {%- endif -%} - <h2 class="post-title"> - <a class="post-link" href="{{ post_url }}"> - {{ post.title | escape }} - </a> - </h2> - <div class="post-meta"> - <span class="post-date"><i class="fa fa-calendar"></i> {{ post.date | date: date_format }}</span> - <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-tags"> - {%- for tag in post.tags -%} - <a class="post-tag" href="{{ '/tags.html ' | relative_url }}#{{tag}}">#{{tag}}</a> - {%- endfor -%} - </div> - </li> + <!-- Normal list item --> + {%- assign post_item_class = "" -%} + {%- for post in paginator.posts -%} + {%- if post.top -%} + {%- continue -%} + {%- endif -%} + {%- include views/pagination-item.html -%} {%- endfor -%} </ul> |