步骤 1:调整文章图片布局

首先你需要确保文章的图片位置为左侧布局。

打开主题配置文件,搜索封面顯示的位置。

1
2
3
# the position of cover in home page (封面顯示的位置)
# left/right/both
position: left

将 position 改为 left。

同时设置 hexo 的页面展示文章数首页文章数最好大于 20 篇。

目前已修复,不过最好多一点不然侧边栏会显得过长。

1
2
3
4
5
6
7
8
# Home page setting
# path: Root path for your blogs index page. (default = '')
# per_page: Posts displayed per page. (0 = disable pagination)
# order_by: Posts order. (Order by date descending by default)
index_generator:
path: ''
per_page: 20
order_by: -date

步骤 2:接入 CSS

打开”\themes\butterfly"路径下的”_config.yml”

搜索到”inject:”设置处

原生添加以下代码或下载 css 从本地导入:

1
2
3
4
inject:
head:
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/Zfour/Butterfly-double-row-display@1.00/cardlistpost.css"/>
bottom:
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#recent-posts{
margin-top:-1rem; /*头部为空时抵消间隔,若有磁贴或日历请注释掉该行*/
align-content:flex-start;
display: flex;
flex-wrap: wrap; /*规定灵活的项目在必要的时候拆行或拆列。*/
justify-content: space-between; /*。*/
}
#recent-posts > .recent-post-item {
/*max-height:324px;*/ /*文章容器最大高度*/
margin-top: 1rem; /*最小间距*/
display: inline-block;
height:auto; /*高度自动*/
width:49%;/*文章容器容器宽度*/
}
#recent-posts > .recent-post-item .post_cover {
width: 100%; /*图片封面宽度*/
height: 200px;/*图片封面高度*/
}
#recent-posts > .recent-post-item .post_cover img.post_bg {
width: 100%;/*图片宽度*/
height: 100%;/*图片高度*/
}


#recent-posts > .recent-post-item >.recent-post-info > .content {
display:none;/*隐藏文章详情*/
}
#recent-posts > .recent-post-item {

-webkit-flex-direction: column; /*容器内部纵向排列*/
-ms-flex-direction: column; /*容器内部纵向排列*/
flex-direction: column; /*容器内部纵向排列*/

}
#recent-posts > .recent-post-item .left_radius {
border-radius: 8px 8px 0 0;/*圆角修改*/
}
#recent-posts > .recent-post-item .right_radius {
border-radius: 8px 8px 0 0;/*圆角修改*/
}
.recent-post-item{
height:auto !important;/*容器高度自动*/
}

.recent-post-info {

padding: 0 40px;/*容器内部文字左右间距*/
margin-top: 1em;/*容器内部文字上间距*/
width: 100%!important;/*容器宽度*/
}
#recent-posts > .recent-post-item > .recent-post-info > .article-title {
-webkit-line-clamp: 1;/*控制标题的行数*/
margin-top: 0.3rem; /*控制标题的上间距*/
margin-bottom: 0.3rem;/*控制标题的下间距*/
color: var(--text-highlight-color);
font-size: 1.2em; /*控制标题的字体大小*/
line-height: 1.4;/*控制标题的行高*/

}
#recent-posts > .recent-post-item >.recent-post-info > .article-meta-wrap {
margin-bottom: 1rem;/*控制标题meta信息的底部间距*/
}
@media screen and (max-width: 768px) {
#recent-posts > .recent-post-item {
width:100%;/*控制手机自适应*/
}

链接进入后,你会发现,布局神奇地变成了双栏布局。


步骤 2:修改 pug

原生主题用户

如果你想让发布时间、分类、标签不在一行显示可以修改 pug。

打开”\themes\hexo-theme-butterfly\layout\includes\mixins\post-ui.pug”。

在__separator 和 i.fas 之间加上换行符 br。

1
2
3
span.article-meta__separator
br
i.fas.fa-tag.article-meta__icon

步骤 4:相关 BUG 解决

在 Android 大佬的指导下已完美解决文章不够时的样式问题,使用新的 cdn 链接即可。