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 /_layouts/post.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 '_layouts/post.html')
-rw-r--r-- | _layouts/post.html | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/_layouts/post.html b/_layouts/post.html index c561308..442cfe6 100644 --- a/_layouts/post.html +++ b/_layouts/post.html @@ -50,7 +50,18 @@ sidebar: <ul> {% assign posts = site[page.collection] | sample:4 %} {%- for post in posts -%} - <li><a class="post-link" href="{{post.url | relative_url}}" title="{{ page.next.title | escape }}">{{ post.title | escape | truncatewords: 12 }}</a></li> + {%- assign post_item_class = "" -%} + {%- if post.top -%} + {%- assign post_item_class = "top-post" -%} + {%- endif -%} + <li class="{{ post_item_class }}"> + <a class="post-link" + href="{{ post.url | relative_url }}" + title="{{ post.title | escape }}"> + {{ post.title | escape | truncatewords: 12 }} + {%- include views/post-badges.html -%} + </a> + </li> {%- endfor -%} </ul> </div> |