posts.liquid
V2 REQUIRED
此模板控制部落格文章在列表頁面中的渲染方式。
將套用於部落格文章列表頁{domain}/blog/posts/{url handle}
,以下為部落格文章列表頁範例內容:
模板變量
以下是一些重要的模板變量和模板方法的說明:
變量名稱 | 數據類型 | 描述 |
---|---|---|
posts | Array | 文章列表数组。 |
post.url | String | 文章的 URL。 |
post.excerpt | String | 文章的摘要。 |
post.title | String | 文章的標題。 |
post.content | String | 這是當前文章的內容。 |
post.date | Date | 文章的發布日期。 |
paginate.previous.is_link | Boolean | 用於判斷是否存在前一頁。 |
paginate.previous.url | String | 前一頁的 URL。 |
paginate.pages | Number | 總頁數。 |
paginate.current_page | Number | 當前頁碼。 |
post_categories | Array | 文章分類列表 |
範例
以下是一個簡單的範例,顯示列表頁文章的摘要、標題、內容和發佈日期:
{% for post in posts %}
<div class="List-item">
<a href="{{ post.url }}">
<div class="List-item-content">
<div class="List-item-excerpt">{{ post.excerpt }}</div>
<div class="List-item-text">
<h2 class="List-item-title">{{ post.title }}</h2>
<div class="List-item-preview">{{ post.content }}</div>
<span class="">{{ post.date }}</span>
</div>
</div>
</a>
</div>
{% endfor %}
Note
該模板屬於 主題私有頁; 詳細說明請查閱 主題私有頁與系統頁
Updated 4 months ago