今天突然閑的蛋疼想把一些文章置頂, 于是就研究了一下如何實現, 還順便把功能塞到了前段時間發布的- Jekyll主題 里面
兩個方案:
Server端實現Client端實現其實很簡單, 一開始以為無法對Post進行操作, 后來發現可以從post的header里面進行參數設置
layout: posttitle: 《10101》EP0:我太受歡迎了該怎么辦category : Comictags : [Comic, 10101]stickie: true然后liquid進行判斷
{* for post in site.posts *} {* if post.stickie != true *} {* continue *} {* endif *} <div>置頂文章細節</div>{* endfor *}{* for post in site.posts *} {* if post.stickie == true *} {* continue *} {* endif *} <div>普通文章細節</div>{* endfor *}當然這個可以進行多種擴展, 比如只輸出特定類別的文章等等,這里就是個只輸出帶有comic這個tag的post
{% for post in site.posts %} {% assign isComic = 0 %} {% for tag in post.tags %} {% if tag == comic %} {% assign isComic = 1 %} {% endif %} {% endfor %} {% if isComic == 0 %} {% continue %} {% endif %}{% endfor %}我太懶了沒去研究 o( ̄▽ ̄)o
用JQuery.sort()給DOM排序再渲染一下即可
這個排序還要額外對時間進行比較//果然懶一點是沒錯的 o( ̄▽ ̄)o
szhshp的第三邊境研究所
新聞熱點
疑難解答