show tag in home article block

This commit is contained in:
Zequn Li 2020-09-02 21:17:03 +01:00
parent 2f51c78b3b
commit e4d6d3eec6
2 changed files with 22 additions and 2 deletions

View File

@ -16,7 +16,7 @@ menu:
Home: / Home: /
Archives: /archives Archives: /archives
# Category: /category # Category: /category
Tags: /tags/ # Tags: /tags/
# Links: /links # Links: /links
# About: /about # About: /about
# ... # ...
@ -106,3 +106,9 @@ magic:
sidebar: sidebar:
enable: false enable: false
position: right # values: left | right position: right # values: left | right
# Home page article block display settings
home_article:
tag: true # show tags in article block
tag_limit: 5 # max number of tags shown in article block
category: true # show category in article block

View File

@ -24,6 +24,7 @@
<div class="article-date"> <div class="article-date">
<span><i class="fa fa-pencil-square-o"></i> <%= date(post.date, 'YYYY-MM-DD') %></span> <span><i class="fa fa-pencil-square-o"></i> <%= date(post.date, 'YYYY-MM-DD') %></span>
<% if (theme.magic.enable === true) { %> <% if (theme.magic.enable === true) { %>
<% if (theme.home_article.category === true) { %>
<span> <span>
<i class="fa fa-folder"></i> <i class="fa fa-folder"></i>
<ul> <ul>
@ -34,6 +35,19 @@
</ul> </ul>
</span> </span>
<% } %> <% } %>
<% if (theme.home_article.tag === true) { %>
<span>
<i class="fa fa-tags"></i>
<ul>
<% post.tags.forEach((tag, i) => {
if (theme.home_article.tag_limit===0 | i+1<= theme.home_article.tag_limit) {%>
<li><%= i === 0 ? '' : '| ' %><a
href="<%- url_for(tag.path) %>"><%= tag.name %></a></li>
<% }}); %>
</ul>
</span>
<% } %>
<% } %>
</div> </div>
<% if (theme.magic.enable === false) { %> <% if (theme.magic.enable === false) { %>
<hr> <hr>