修改article-sort.pug

打开[you_blog]\themes\butterfly\layout\includes\mixins\article-sort.pug文件。

替换为以下代码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
mixin articleSort(posts, current)
.article-sort
- var year
- posts.each(function (article, post_index) {
- let tempYear = date(article.date, 'YYYY')
- let no_cover = article.cover === false || !theme.cover.archives_enable ? 'no-article-cover' : ''
- let title = article.title || _p('no_title')
if tempYear !== year
- year = tempYear
.article-sort-item.year= year
.article-sort-item(class=no_cover)
if article.cover && theme.cover.archives_enable
a.article-sort-item-img(href=url_for(article.path) title=title)
img(src=url_for(article.cover) alt=title onerror=`this.onerror=null;this.src='${url_for(theme.error_img.post_page)}'`)
.article-sort-item-info
a.article-sort-item-title(href=url_for(article.path) title=title)= title
span.article-sort-item-index= (current - 1) * config.per_page + post_index + 1
.article-meta-wrap
if (theme.post_meta.page.categories && article.categories.data.length > 0)
span.article-sort-item-categories
i.fas.fa-inbox
each item, index in article.categories.data
a(href=url_for(item.path)).article-meta__categories #[=item.name]
if (index < article.categories.data.length - 1)
i.fas.fa-angle-right
if (theme.post_meta.page.tags && article.tags.data.length > 0)
span.article-sort-item-tags
i.fas.fa-tag
each item, index in article.tags.data
a(href=url_for(item.path)).article-meta__tags #[=item.name]
if (index < article.tags.data.length - 1)
span.article-meta__link #[='•']
.article-sort-item-time
i.far.fa-calendar-alt
time.post-meta-date-created(datetime=date_xml(article.date) title=_p('post.created') + ' ' + full_date(article.date))= date(article.date, config.date_format)
- })

修改归档、分类、标签页面

修改[you_blog]\themes\butterfly\layout\archive.pug

1
2
3
4
5
6
7
8
9
extends includes/layout.pug

block content
include ./includes/mixins/article-sort.pug
#archive
.article-sort-title= _p('page.articles') + ' - ' + site.posts.length
- +articleSort(page.posts)
+ +articleSort(page.posts, page.current)
include includes/pagination.pug

修改[you_blog]\themes\butterfly\layout\category.pug

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
extends includes/layout.pug

block content
if theme.category_ui == 'index'
include ./includes/mixins/post-ui.pug
#recent-posts.recent-posts.category_ui
+postUI
include includes/pagination.pug
else
include ./includes/mixins/article-sort.pug
#category
.article-sort-title= _p('page.category') + ' - ' + page.category
- +articleSort(page.posts)
+ +articleSort(page.posts, page.current)
include includes/pagination.pug

修改[you_blog]\themes\butterfly\layout\tag.pug

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
extends includes/layout.pug

block content
if theme.tag_ui == 'index'
include ./includes/mixins/post-ui.pug
#recent-posts.recent-posts
+postUI
include includes/pagination.pug
else
include ./includes/mixins/article-sort.pug
#tag
.article-sort-title= _p('page.tag') + ' - ' + page.tag
- +articleSort(page.posts)
+ +articleSort(page.posts, page.current)
include includes/pagination.pug

增加文章索引样式

在自定义css中加入以下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/* 分类标签归档页增加文章索引start */
.article-sort-item-title {
font-size: 1.2rem;
}
.article-meta-wrap,
.article-sort-item-time {
font-size: .9rem;
}
.article-sort-item-index {
opacity: 0.5;
position: absolute;
top: 0.5rem;
right: 0.5rem;
font-style: italic;
font-size: 2.5rem;
line-height: 1.5rem;
}
#archive span.article-sort-item-categories,
#archive span.article-sort-item-tags {
padding-right: 1em;
}
#archive span.article-sort-item-categories i,
#archive span.article-sort-item-tags i {
padding-right: .5em;
}
#archive span.article-sort-item-tags span {
padding-left: .5em;
padding-right: .5em;
}
/* 分类标签归档页增加文章索引end */

参考链接

15-新标签打开文章 13-404页面展示最近文章