feat:增加近期更新的列表,默认10条。

This commit is contained in:
徐涛 2021-05-12 23:15:58 +08:00
parent 771f4f9ff8
commit 9206dca1b5
7 changed files with 72 additions and 1 deletions

View File

@ -87,6 +87,7 @@ updated_option: "mtime"
## Set per_page to 0 to disable pagination ## Set per_page to 0 to disable pagination
per_page: 10 per_page: 10
pagination_dir: page pagination_dir: page
recent_per_page: 10
# Include / Exclude file(s) # Include / Exclude file(s)
## include:/exclude: options only apply to the 'source/' folder ## include:/exclude: options only apply to the 'source/' folder

4
source/recently/index.md Normal file
View File

@ -0,0 +1,4 @@
---
title: 最近更新
layout: "recently"
---

View File

@ -1,3 +1,5 @@
# Parameters
# Less # Less
less: less:
paths: [] paths: []

View File

@ -9,6 +9,7 @@
<% if (!is_home()) { %> <% if (!is_home()) { %>
<li><a href="/index.html">返回首页</a></li> <li><a href="/index.html">返回首页</a></li>
<% } %> <% } %>
<li<% if (is_current('/recently')) { %> class="uk-active"<% } %>><a href="/recently">近期更新</a></li>
<li<% if (is_current('/categories')) { %> class="uk-active"<% } %>><a href="/categories">知识分类</a></li> <li<% if (is_current('/categories')) { %> class="uk-active"<% } %>><a href="/categories">知识分类</a></li>
<li<% if (is_current('/tags')) { %> class="uk-active"<% } %>><a href="/tags">知识标签</a></li> <li<% if (is_current('/tags')) { %> class="uk-active"<% } %>><a href="/tags">知识标签</a></li>
<li<% if (is_archive()) { %> class="uk-active"<% } %>><a href="/archives">归档文章</a></li> <li<% if (is_archive()) { %> class="uk-active"<% } %>><a href="/archives">归档文章</a></li>
@ -23,6 +24,7 @@
<% if (!is_home()) { %> <% if (!is_home()) { %>
<li><a href="/index.html">返回首页</a></li> <li><a href="/index.html">返回首页</a></li>
<% } %> <% } %>
<li<% if (is_current('/recently')) { %> class="uk-active"<% } %>><a href="/recently">近期更新</a></li>
<li<% if (is_current('/categories')) { %> class="uk-active"<% } %>><a href="/categories">知识分类</a></li> <li<% if (is_current('/categories')) { %> class="uk-active"<% } %>><a href="/categories">知识分类</a></li>
<li<% if (is_current('/tags')) { %> class="uk-active"<% } %>><a href="/tags">知识标签</a></li> <li<% if (is_current('/tags')) { %> class="uk-active"<% } %>><a href="/tags">知识标签</a></li>
<li<% if (is_archive()) { %> class="uk-active"<% } %>><a href="/archives">归档文章</a></li> <li<% if (is_archive()) { %> class="uk-active"<% } %>><a href="/archives">归档文章</a></li>

View File

@ -0,0 +1,43 @@
<% site.posts.sort("updated", "desc").slice(0, config.recent_per_page).each(function(post, i) { %>
<div class="uk-card uk-card-default uk-card-small uk-width-1-1 mb-2">
<div class="uk-card-header">
<h3 class="uk-card-title">
<a href="/<%= post.path %>">
<%= post.title %>
</a>
</h3>
<div class="flex row-a col-n rm-start-a">
<div class="uk-text-meta mr-1">发布:<%= date(post.date, "YYYY-MM-DD HH:mm") %></div>
<% const updateValid = post.updated.isValid() %>
<div class="uk-text-meta mr-1">更新:<%= date(updateValid ? post.updated : post.date, "YYYY-MM-DD HH:mm") %></div>
<% if (post.categories.length> 0) { %>
<div class="uk-text-meta">知识分类:
<%- list_categories(post.categories, {
class: { a: 'uk-link-muted' },
show_count: false,
style: false,
separator: ' / '
}) %>
</div>
<% } %>
</div>
</div>
<% if (post.excerpt) { %>
<div class="uk-card-body">
<%- post.excerpt %>
</div>
<% } %>
<% if (post.tags.length> 0) { %>
<div class="uk-card-footer flex row-a rm-start-a hin">
<div class="tag-title">分类标签:</div>
<div class="flex row-a rm-start-a w-wrap-a extend-1-a">
<% post.tags.each(function(tag) { %>
<span class="uk-label ml-1 mb-1 <% if (is_tag(tag.name)) { %>uk-label-warning<% } %>">
<%= tag.name %>
</span>
<% }) %>
</div>
</div>
<% } %>
</div>
<% }) %>

View File

@ -0,0 +1,19 @@
<div class="flex mx-2 my-2 main-content">
<section class="w-3-4-a w-2-2-m px-1 extend-1-a">
<%- partial('partial/post/update-list', {start: 1}) %>
<% if (page.total > 1) { %>
<div class="flex rm-between-a p-1">
<a class="<% if (page.prev == 0) { %>uk-disabled<% } %>"
href="/<%- page.prev_link %>"
uk-slidenav-previous></a>
<a class="<% if (page.next == 0) { %>uk-disabled<% } %>"
href="/<%- page.next_link %>"
uk-slidenav-next
></a>
</div>
<% } %>
</section>
<section class="w-1-4-a flex col-a hin him">
<%- partial('partial/side', {'noCategories': false, 'noTags': false}) %>
</section>
</div>