2020-03-19 18:11:13 +08:00
|
|
|
<div class="home-container">
|
|
|
|
<!-- 检查当前页面是否为首页 -->
|
|
|
|
<% if (is_home()) { %>
|
2020-03-18 23:14:09 +08:00
|
|
|
<ul class="article-post-list">
|
|
|
|
<% page.posts.forEach(post => { %>
|
|
|
|
<li class="article-post-item">
|
|
|
|
<div class="article-post-title">
|
|
|
|
<h3>
|
|
|
|
<a href="<%- url_for(post.path) %>"><%= post.title %></a>
|
|
|
|
</h3>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="article-post-content">
|
2020-03-19 14:51:48 +08:00
|
|
|
<!-- truncate() 移除超过 length 长度的字符串。length 的默认值是 30。 -->
|
|
|
|
<%- truncate(strip_html(post.content), {length: 80}) %>
|
2020-03-18 23:14:09 +08:00
|
|
|
</div>
|
|
|
|
|
2020-03-19 23:08:51 +08:00
|
|
|
<!-- date -->
|
|
|
|
<div class="article-meta">
|
|
|
|
<span class="article-date article-item">
|
|
|
|
<i class="fa fa-calendar-o"></i>
|
|
|
|
<%= date(post.date, 'YYYY-MM-DD HH:MM:SS') %>
|
|
|
|
</span>
|
|
|
|
|
|
|
|
<!-- categories -->
|
|
|
|
<% if (post.categories.length) { %>
|
|
|
|
<span class="article-categories article-item">
|
|
|
|
<i class="fa fa-bookmark"></i>
|
|
|
|
<ul>
|
|
|
|
<% post.categories.forEach((category, i) => { %>
|
|
|
|
<li>
|
|
|
|
<%= i === 0 ? '' : '| ' %><a href="<%- url_for(category.path) %>"
|
|
|
|
rel="tag"><%= category.name %></a>
|
|
|
|
</li>
|
|
|
|
<% }); %>
|
|
|
|
</ul>
|
|
|
|
</span>
|
|
|
|
<% } %>
|
|
|
|
|
|
|
|
<!-- tags -->
|
|
|
|
<% if (post.tags.length) { %>
|
|
|
|
<span class="article-tags article-item">
|
|
|
|
<i class="fa fa-tags"></i>
|
|
|
|
<ul>
|
|
|
|
<% post.tags.forEach((tag, i) => { %>
|
|
|
|
<li>
|
|
|
|
<%= i === 0 ? '' : '| ' %><a href="<%- url_for(tag.path) %>"
|
|
|
|
rel="tag"><%= tag.name %></a>
|
|
|
|
</li>
|
|
|
|
<% }); %>
|
|
|
|
</ul>
|
|
|
|
</span>
|
|
|
|
<% } %>
|
2020-03-18 23:14:09 +08:00
|
|
|
</div>
|
|
|
|
</li>
|
|
|
|
<% }) %>
|
|
|
|
</ul>
|
|
|
|
<% } %>
|
|
|
|
|
|
|
|
<!-- 分页器 -->
|
|
|
|
<%- partial('paginator') %>
|
|
|
|
|
|
|
|
</div>
|