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/segments.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/segments.html')
-rw-r--r-- | _includes/views/segments.html | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/_includes/views/segments.html b/_includes/views/segments.html index 2c92dc1..0cf9414 100644 --- a/_includes/views/segments.html +++ b/_includes/views/segments.html @@ -13,7 +13,13 @@ {% assign items = site.posts | where: field, key %} {% for item in items %} {% if item != nil %} - <li> {% include views/post-item.html %} </li> + {%- assign post_item_class = "" -%} + {%- if item.top -%} + {%- assign post_item_class = "top-post" -%} + {%- endif -%} + <li class="{{ post_item_class }}"> + {%- include views/post-item.html -%} + </li> {% endif %} {% endfor %} {% endfor %} |