Skip to content

Commit 00a3a6b

Browse files
committed
feat: 添加更新日期显示功能
1 parent beb74d7 commit 00a3a6b

File tree

7 files changed

+44
-7
lines changed

7 files changed

+44
-7
lines changed

_config.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,9 @@ tagcloud_limits:
149149
# Archive behavior
150150
only_show_capsule_in_index: false # If you have hugo amounts of tags and categories, you can set this to true to only show the capsule in the index page for better performance
151151

152+
show_update_time: false # If you want to show the update time, please set this to true
153+
154+
# Internationalization
152155
i18n:
153156
enable: false
154157
type: [page, post]
@@ -169,7 +172,7 @@ reimu_cursor:
169172
text: ../images/cursor/reimu-cursor-text.png
170173

171174
# set to false to enable fontawesome
172-
icon_font: 4552607_cp3b72wuupu
175+
icon_font: 4552607_cs6s86l0wm9
173176

174177
# Font loading strategy
175178
# Custom Font -> Google Fonts -> Local FallBack Font

layout/_partial/post.ejs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
<div class="post-info">
2424
<div class="post-meta">
2525
<span><span class="icon-calendar"></span><%- date(post.date, "YYYY-MM-DD") %></span>
26+
<% if (theme.show_update_time) { %>
27+
<span><span class="icon-calendar-plus"></span><%- date(post.updated, "YYYY-MM-DD") %></span>
28+
<% } %>
2629
<span><span class="icon-pencil"></span><%= _p('post.count', wordcount(post.content, post._id)) %></span>
2730
<span><span class="icon-clock"></span><%= _p('post.time', min2read(post.content, {}, post._id)) %></span>
2831
</div>

layout/_partial/post/date.ejs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
<div class="<%= class_name %>">
2-
<span class="article-date-link" data-aos="<%= theme.animation.options.article.date %>">
2+
<span class="article-date-link icon-calendar" data-aos="<%= theme.animation.options.article.date %>">
33
<time datetime="<%= date_xml(post.date) %>" itemprop="datePublished"><%= date(post.date, date_format) %></time>
44
<time style="display: none;" id="post-update-time"><%= date(post.updated, date_format) %></time>
55
</span>
6+
<% if (theme.show_update_time) { %>
7+
<span class="article-date-link icon-calendar-plus" data-aos="<%= theme.animation.options.article.date %>">
8+
<time datetime="<%= date_xml(post.updated) %>" itemprop="datePublished"><%= date(post.updated, date_format) %></time>
9+
</span>
10+
<% } %>
611
</div>

source/css/_partial/post.styl

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,16 +61,29 @@ $post-wrap
6161
span
6262
font-size: 14px
6363
color: var(--grey-7)
64-
margin: 0 8px
64+
margin: 0 12px
6565
white-space: nowrap
6666
text-overflow: ellipsis
6767
overflow: hidden
6868

69-
span:before
70-
margin: 0 10px
71-
7269
@media mg-normal
73-
margin: 0
70+
margin: 0 8px
71+
72+
if hexo-config('show_update_time')
73+
> span
74+
@media mg-extra-large
75+
margin: 0 8px
76+
@media mg-large
77+
margin: 0 6px
78+
@media mq-mobile
79+
margin: 0 2px
80+
span
81+
@media mg-extra-large
82+
margin: 0 6px
83+
@media mg-large
84+
margin: 0 4px
85+
@media mq-mobile
86+
margin: 0 3px
7487

7588
.post-article
7689
display: -webkit-box

source/css/_variables.styl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,5 +144,7 @@ mq-normal = "screen and (min-width: 768px)"
144144
mg-normal = "screen and (max-width: 767px)"
145145
mq-large = "screen and (min-width: 960px)"
146146
mg-large = "screen and (max-width: 959px)"
147+
mq-extra-large = "screen and (min-width: 1242px)"
148+
mg-extra-large = "screen and (max-width: 1241px)"
147149

148150
post-radius = 10px

source/css/fontawesome.styl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,12 @@
124124
content: "\f133"
125125
font-weight: 900
126126

127+
.icon-calendar-plus
128+
&:before
129+
font-family: var(--font-icon)
130+
content: "\f271"
131+
font-weight: 900
132+
127133
.icon-pencil
128134
&:before
129135
font-family: var(--font-icon)

source/css/iconfont.styl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,11 @@ _a = '//at.alicdn.com/t/c/font_' + id + '.woff2'
121121
font-family: font-icon
122122
content: "\e605"
123123

124+
.icon-calendar-plus
125+
&:before
126+
font-family: font-icon
127+
content: "\e648"
128+
124129
.icon-pencil
125130
&:before
126131
font-family: font-icon

0 commit comments

Comments
 (0)