本站使用的主题:butterfly 4.2.2

相关推荐版块侧栏卡片化

See:https://akilar.top/posts/194e1534/

[Blogroot]\themes\butterfly\scripts\helpers\related_post.js 47~71 行

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
if (relatedPosts.length > 0) {
result += '<div class="card-widget card-recommend-post">'
result += `<div class="item-headline"><i class="fas fa-dharmachakra"></i><span>${headlineLang}</span></div>`
result += '<div class="aside-list">'
for (let i = 0; i < Math.min(relatedPosts.length, limitNum); i++) {
const cover =
relatedPosts[i].cover === false
? relatedPosts[i].randomcover
: relatedPosts[i].cover
result += `<div class="aside-list-item">`
result += `<a class="thumbnail" href="${this.url_for(relatedPosts[i].path)}" title="${relatedPosts[i].title}"><img src="${this.url_for(cover)}" alt="${relatedPosts[i].title}"></a>`
result += `<div class="content">`
result += `<a class="title" href="${this.url_for(relatedPosts[i].path)}" title="${relatedPosts[i].title}">${relatedPosts[i].title}</a>`
if (dateType === 'created') {
result += `<time datetime="${this.date(relatedPosts[i].created, hexoConfig.date_format)}" title="发表于 ${this.date(relatedPosts[i].created, hexoConfig.date_format)}">${this.date(relatedPosts[i].created, hexoConfig.date_format)}</time>`
} else {
result += `<time datetime="${this.date(relatedPosts[i].updated, hexoConfig.date_format)}" title="发表于 ${this.date(relatedPosts[i].updated, hexoConfig.date_format)}">${this.date(relatedPosts[i].updated, hexoConfig.date_format)}</time>`
}
result += `</div></div>`
}
result += '</div></div>'
return result
}

[Blogroot]\themes\butterfly\layout\post.pug 26~27 行

1
2
3
4
5
6
  if theme.post_pagination
include includes/pagination.pug
- if theme.related_post && theme.related_post.enable
- != related_posts(page,site.posts)

if page.comments !== false && theme.comments && theme.comments.use

[Blogroot]\themes\butterfly\layout\includes\widget\index.pug 16~17 行

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#aside-content.aside-content
//- post
if is_post()
if showToc && theme.toc.style_simple
.sticky_layout
include ./card_post_toc.pug
else
!=partial('includes/custom/SAO_card_player', {}, {cache:true})
!=partial('includes/widget/card_announcement', {}, {cache:true})
!=partial('includes/widget/card_top_self', {}, {cache:true})
.sticky_layout
if showToc
include ./card_post_toc.pug
+ if theme.related_post && theme.related_post.enable
+ != related_posts(page,site.posts)
- - !=partial('includes/widget/card_recent_post', {}, {cache:true})
!=partial('includes/widget/card_ad', {}, {cache:true})

修改加载动画内容

See:https://akilar.top/posts/3d221bf2/

[Blogroot]\themes\butterfly\layout\includes\loading\loading.pug 全部

1
2
3
4
if theme.preloader.enable
case theme.preloader.load_style
when 'gear'
include ./load_style/gear.pug

新建 [Blogroot]\themes\butterfly\layout\includes\loading\load_style\gear.pug

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#loading-box
.gear-loader
.gear-loader_overlay
.gear-loader_cogs
.gear-loader_cogs__top
.gear-top_part
.gear-top_part
.gear-top_part
.gear-top_hole
.gear-loader_cogs__left
.gear-left_part
.gear-left_part
.gear-left_part
.gear-left_hole
.gear-loader_cogs__bottom
.gear-bottom_part
.gear-bottom_part
.gear-bottom_part
.gear-bottom_hole

[Blogroot]\themes\butterfly\source\css\_layout\loading.styl 全部

1
2
3
if hexo-config('preloader.enable')
if hexo-config('preloader.load_style') == 'gear'
@import './_load_style/gear'

新建 [Blogroot]\themes\butterfly\source\css\_load_style\gear.styl

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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
#loading-box
position fixed
z-index 1000
width 100vw
height 100vh
overflow hidden
text-align center
&.loaded
z-index -1000
.gear-loader
display none
.gear-loader
height 100%
position relative
margin auto
width 400px
.gear-loader_overlay
width 150px
height 150px
background transparent
box-shadow 0px 0px 0px 1000px rgba(255, 255, 255, 0.67), 0px 0px 19px 0px rgba(0, 0, 0, 0.16) inset
border-radius 100%
z-index -1
position absolute
left 0
right 0
top 0
bottom 0
margin auto
.gear-loader_cogs
z-index -2
width 100px
height 100px
top -120px !important
position absolute
left 0
right 0
top 0
bottom 0
margin auto
.gear-loader_cogs__top
position relative
width 100px
height 100px
transform-origin 50px 50px
-webkit-animation rotate 10s infinite linear
animation rotate 10s infinite linear
div
&:nth-of-type(1)
transform rotate(30deg)
&:nth-of-type(2)
transform rotate(60deg)
&:nth-of-type(3)
transform rotate(90deg)
&.gear-top_part
width 100px
border-radius 10px
position absolute
height 100px
background #f98db9
&.gear-top_hole
width 50px
height 50px
border-radius 100%
background white
position absolute
position absolute
left 0
right 0
top 0
bottom 0
margin auto
.gear-loader_cogs__left
position relative
width 80px
transform rotate(16deg)
top 28px
transform-origin 40px 40px
animation rotate_left 10s 0.1s infinite reverse linear
left -24px
height 80px
div
&:nth-of-type(1)
transform rotate(30deg)
&:nth-of-type(2)
transform rotate(60deg)
&:nth-of-type(3)
transform rotate(90deg)
&.gear-left_part
width 80px
border-radius 6px
position absolute
height 80px
background #97ddff
&.gear-left_hole
width 40px
height 40px
border-radius 100%
background white
position absolute
position absolute
left 0
right 0
top 0
bottom 0
margin auto
.gear-loader_cogs__bottom
position relative
width 60px
top -65px
transform-origin 30px 30px
-webkit-animation rotate_left 10.2s 0.4s infinite linear
animation rotate_left 10.2s 0.4s infinite linear
transform rotate(4deg)
left 79px
height 60px
div
&:nth-of-type(1)
transform rotate(30deg)
&:nth-of-type(2)
transform rotate(60deg)
&:nth-of-type(3)
transform rotate(90deg)
&.gear-bottom_part
width 60px
border-radius 5px
position absolute
height 60px
background #ffcd66
&.gear-bottom_hole
width 30px
height 30px
border-radius 100%
background white
position absolute
position absolute
left 0
right 0
top 0
bottom 0
margin auto



/* Animations */
@-webkit-keyframes rotate {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
@keyframes rotate {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
@-webkit-keyframes rotate_left {
from {
transform: rotate(16deg);
}
to {
transform: rotate(376deg);
}
}
@keyframes rotate_left {
from {
transform: rotate(16deg);
}
to {
transform: rotate(376deg);
}
}
@-webkit-keyframes rotate_right {
from {
transform: rotate(4deg);
}
to {
transform: rotate(364deg);
}
}
@keyframes rotate_right {
from {
transform: rotate(4deg);
}
to {
transform: rotate(364deg);
}
}

[Blogroot]\themes\butterfly\layout\includes\layout.pug 11 行

1
2
3
4
    body
- if theme.preloader
+ if theme.preloader.enable
!=partial('includes/loading/loading', {}, {cache: true})

[Blogroot]\themes\butterfly\source\css\var.styl 101 行

1
2
3
4
      // preloader
- $preloader-bg = #37474f
+ $preloader-bg = hexo-config('preloader.enable') && hexo-config('preloader.load_color') ? convert(hexo-config('preloader.load_color')) : #37474f
$preloader-word-color = #fff

[Blogroot]\themes\butterfly\layout\includes\loading\loading-js.pug 全部

1
2
3
4
5
6
7
8
9
10
11
12
13
14
script(async).
var preloader = {
endLoading: () => {
document.body.style.overflow = 'auto';
document.getElementById('loading-box').classList.add("loaded")
},
initLoading: () => {
document.body.style.overflow = '';
document.getElementById('loading-box').classList.remove("loaded")

}
}
window.addEventListener('load',preloader.endLoading())
document.getElementById('loading-box').addEventListener('click',()=> {preloader.endLoading()})

友链样式魔改

See:https://akilar.top/posts/57291286/

[Blogroot]\themes\butterfly\layout\includes\page\flink.pug 全部

1
2
3
case theme.flink_style
when 'flexcard'
include ./flink_style/flexcard.pug

新建 [Blogroot]\themes\butterfly\layout\includes\page\flink_style\flexcard.pug

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#article-container
if top_img === false
h1.page-title= page.title
.flink
if site.data.link
each i in site.data.link
if i.class_name
h2!= i.class_name
if i.class_desc
.flink-desc!=i.class_desc
.flink-list
each item in i.link_list
a.flink-list-card(href=url_for(item.link) target='_blank' data-title=item.descr)
.wrapper.cover
- var siteshot = item.siteshot ? url_for(item.siteshot) : 'https://image.thum.io/get/width/400/crop/800/allowJPG/wait/20/noanimate/' + item.link
img.no-lightbox.cover.fadeIn(src=siteshot onerror=`this.onerror=null;this.src='` + url_for(theme.error_img.post_page) + `'` alt='' )
.info
img.no-lightbox(src=url_for(item.avatar) onerror=`this.onerror=null;this.src='` + url_for(theme.error_img.flink) + `'` alt='' )
span.flink-sitename= item.name
!= page.content

[Blogroot]\themes\butterfly\source\css\_page\flink.styl 全部

1
2
if hexo-config('flink_style') == 'flexcard'
@import './_flink_style/flexcard'

新建 [Blogroot]\themes\butterfly\source\css\_flink_style\flexcard.styl

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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
.flink-list
overflow auto
& > a
width calc(25% - 15px)
height 130px
position relative
display block
margin 15px 7px
float left
overflow hidden
border-radius 10px
transition all .3s ease 0s, transform .6s cubic-bezier(.6, .2, .1, 1) 0s
box-shadow 0 14px 38px rgba(0, 0, 0, .08), 0 3px 8px rgba(0, 0, 0, .06)
&:hover
.info
transform translateY(-100%)
.wrapper
img
transform scale(1.2)
&::before
position: fixed
width:inherit
margin:auto
left:0
right:0
top:10%
border-radius: 10px
text-align: center
z-index: 100
content: attr(data-title)
font-size: 20px
color: #fff
padding: 10px
background-color: rgba($theme-color,0.8)

.cover
width 100%
transition transform .5s ease-out
.wrapper
position relative
.fadeIn
animation coverIn .8s ease-out forwards
img
height 130px
pointer-events none
.info
display flex
flex-direction column
justify-content center
align-items center
width 100%
height 100%
overflow hidden
border-radius 3px
background-color hsla(0, 0%, 100%, .7)
transition transform .5s cubic-bezier(.6, .2, .1, 1) 0s
img
position relative
top 22px
width 66px
height 66px
border-radius 50%
box-shadow 0 0 10px rgba(0, 0, 0, .3)
z-index 1
text-align center
pointer-events none
span
padding 20px 10% 60px 10%
font-size 16px
width 100%
text-align center
box-shadow 0 0 10px rgba(0, 0, 0, .3)
background-color hsla(0, 0%, 100%, .7)
color var(--font-color)
white-space nowrap
overflow hidden
text-overflow ellipsis
.flink-list>a .info,
.flink-list>a .wrapper .cover
position absolute
top 0
left 0

@media screen and (max-width:1024px)
.flink-list
& > a
width calc(33.33333% - 15px)

@media screen and (max-width:600px)
.flink-list
& > a
width calc(50% - 15px)

[data-theme=dark]
.flink-list a .info,
.flink-list a .info span
background-color rgba(0, 0, 0, .6)
.flink-list
& > a
&:hover
&:before
background-color: rgba(#121212,0.8);
.justified-gallery > div > img,
.justified-gallery > figure > img,
.justified-gallery > a > a > img,
.justified-gallery > div > a > img,
.justified-gallery > figure > a > img,
.justified-gallery > a > svg,
.justified-gallery > div > svg,
.justified-gallery > figure > svg,
.justified-gallery > a > a > svg,
.justified-gallery > div > a > svg,
.justified-gallery > figure > a > svg
position static!important

时间轴生肖图标

See:https://akilar.top/posts/22257072/

新建 [Blogroot]\themes\butterfly\scripts\year.js

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
hexo.extend.helper.register('getAnimalIcon', function (year) {
var index = parseInt(year) % 12;
var icon = {
0: 'icon-monkey',
1: 'icon-rooster',
2: 'icon-dog',
3: 'icon-boar',
4: 'icon-rat',
5: 'icon-ox',
6: 'icon-tiger',
7: 'icon-rabbit',
8: 'icon-dragon',
9: 'icon-snake',
10: 'icon-horse',
11: 'icon-goat',
}
return icon[index]
});

[Blogroot]\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
mixin articleSort(posts)
.article-sort
- var year
- posts.each(function (article) {
- 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')
- let iconAnimal = '#'+ getAnimalIcon(tempYear)
if tempYear !== year
- year = tempYear
.article-sort-item.year
span= year
svg.icon(aria-hidden='true' style='width: 1em!important; height: 1em!important;')
use(xlink:href=iconAnimal)
.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
.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)
a.article-sort-item-title(href=url_for(article.path) title=title)= title
- })

节日挂件

See:https://akilar.top/posts/23fdf850/

新建 [Blogroot]\themes\butterfly\scripts\festival.js

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
hexo.extend.helper.register('getFestivalIcon', function () {
var icon = [
'#icon-qiandai',
'#icon-denglong',
'#icon-juanzhou',
'#icon-hongbao',
'#icon-duilian',
'#icon-bianpao',
'#icon-shanzi',
'#icon-tangguo',
'#icon-yuanbao',
'#icon-qianchuan',
'#icon-denglong2'
]
var index = Math.floor(Math.random()*icon.length);
return icon[index]
});

[Blogroot]\themes\butterfly\layout\includes\mixins\post-ui.pug 14~19 行

1
2
3
4
5
6
if post_cover && theme.cover.index_enable
.post_cover(class=leftOrRight)
a(href=url_for(link) title=title)
svg.icon.festival-decoration(aria-hidden="true")
use(xlink:href=getFestivalIcon())
img.post_bg(src=url_for(post_cover) onerror=`this.onerror=null;this.src='`+ url_for(theme.error_img.post_page) + `'` alt=title)

Swiper Bar

See:https://akilar.top/posts/8e1264d1/

新建 [Blogroot]\themes\butterfly\layout\includes\sliderbar.pug

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
.blog-slider.swiper-container-fade.swiper-container-horizontal#swiper_container
.blog-slider__wrp.swiper-wrapper(style='transition-duration: 0ms;')
if site.data.slider
each i in site.data.slider
.blog-slider__item.swiper-slide(style='width: 750px; opacity: 1; transform: translate3d(0px, 0px, 0px); transition-duration: 0ms;')
a.blog-slider__img(href=url_for(i.link) alt='')|
img(width='48' height='48' src=url_for(i.cover) onerror=`this.onerror=null;this.src='` + url_for(theme.error_img.post_page) + `'`, alt='')
.blog-slider__content
span.blog-slider__code= i.timeline
a.blog-slider__title(href=url_for(i.link) alt='')= i.title
.blog-slider__text= i.description
a.blog-slider__button(href=url_for(i.link) alt='')= i.button
.blog-slider__pagination.swiper-pagination-clickable.swiper-pagination-bullets
script(defer src=url_for(theme.CDN.swiper_js))
script(defer data-pjax src=url_for(theme.CDN.swiper_init))

[Blogroot]\themes\butterfly\layout\index.pug

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

block content
include ./includes/mixins/post-ui.pug
#recent-posts.recent-posts
+ .recent-post-item(style='height:auto;width:100%;')
+ !=partial('includes/sliderbar', {}, {cache:true})
+postUI
include includes/pagination.pug

新建 [Blogroot]\themes\butterfly\source\css\_layout\swiperstyle.styl

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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
*
box-sizing border-box
div#swiper_container
background rgba(255, 255, 255, 0);
.blog-slider
width 100%
position relative
border-radius 12px 8px 8px 12px
margin auto
background var(--global-bg)
padding: 10px
transition all .3s

.blog-slider__item
display flex
align-items center
&.swiper-slide-active
.blog-slider__img
img
opacity 1
transition-delay .3s
.blog-slider__content
& > *
opacity 1
transform none
& > *:nth-child(1)
transition-delay 0.3s
& > *:nth-child(2)
transition-delay 0.4s
& > *:nth-child(3)
transition-delay 0.5s
& > *:nth-child(4)
transition-delay 0.6s
& > *:nth-child(5)
transition-delay 0.7s
& > *:nth-child(6)
transition-delay 0.8s
& > *:nth-child(7)
transition-delay 0.9s
& > *:nth-child(8)
transition-delay 1s
& > *:nth-child(9)
transition-delay 1.1s
& > *:nth-child(10)
transition-delay 1.2s
& > *:nth-child(11)
transition-delay 1.3s
& > *:nth-child(12)
transition-delay 1.4s
& > *:nth-child(13)
transition-delay 1.5s
& > *:nth-child(14)
transition-delay 1.6s
& > *:nth-child(15)
transition-delay 1.7s



.blog-slider__img
width 200px
flex-shrink 0
height 200px
padding 10px
border-radius 5px
transform translateX(0px)
overflow hidden
&:after
content ''
position absolute
top 0
left 0
width 100%
height 100%
border-radius 5px
opacity 0.8
img
width 100%
height 100%
object-fit cover
display block
opacity 0
border-radius 5px
transition all .3s

.blog-slider__content
padding-right 50px
padding-left 50px
& > *
opacity 0
transform translateY(25px)
transition all .4s


.blog-slider__code
color var(--font-color)
margin-bottom 0px
display block
font-weight 500

.blog-slider__title
font-size 18px
font-weight 700
color var(--font-color)
margin-bottom 15px
-webkit-line-clamp 1
display -webkit-box
overflow hidden
-webkit-box-orient vertical

.blog-slider__text
color var(--font-color)
-webkit-line-clamp 1
display -webkit-box
overflow hidden
-webkit-box-orient vertical
margin-bottom 15px
line-height 1.5em
width 100%
display block
word-break break-all
word-wrap break-word

.blog-slider__button
display inline-flex
background-color var(--btn-bg)
padding 4px 14px
border-radius 8px
color var(--btn-color)
text-decoration none
font-weight 500
justify-content center
text-align center
letter-spacing 1px
display none
&:hover
background-color var(--btn-hover-color)
color var(--btn-color)

.blog-slider .swiper-container-horizontal > .swiper-pagination-bullets, .blog-slider .swiper-pagination-custom, .blog-slider .swiper-pagination-fraction
bottom 10px
left 0
width 100%

.blog-slider__pagination
position absolute
z-index 21
right 20px
width 11px !important
text-align center
left auto !important
top 50%
bottom auto !important
transform translateY(-50%)
&.swiper-pagination-bullets
.swiper-pagination-bullet
margin 8px 0
.swiper-pagination-bullet
width 11px
height 11px
display block
border-radius 10px
background #858585
opacity 0.2
transition all .3s
.swiper-pagination-bullet-active
opacity 1
background var(--btn-bg)
height 30px

@media screen and (max-width: 600px)
.blog-slider__pagination
transform translateX(-50%)
left 50% !important
top 320px
width 100% !important
display flex
justify-content center
align-items center

.blog-slider__pagination
&.swiper-pagination-bullets
.swiper-pagination-bullet
margin 0 5px

.blog-slider__pagination
.swiper-pagination-bullet-active
height 11px
width 30px

.blog-slider__button
display inline-flex
width 100%
.blog-slider__text
margin-bottom 40px

.blog-slider
min-height 350px
height auto
margin-top 110px
margin-bottom 10px

.blog-slider__content
margin-top -80px
text-align center
padding 0 30px

.blog-slider__item
flex-direction column

.blog-slider__img
transform translateY(-50%)
width 90%



.blog-slider__content
padding-left 10px
padding-right 10px

.blog-slider__pagination.swiper-pagination-clickable.swiper-pagination-bullets
top 110px


@media screen and (min-width: 600px)
.blog-slider
height 200px

.blog-slider__img
height 200px

[Blogroot]\themes\butterfly\source\css\index.styl 第 1 行

1
+ @import url(hexo-config('CDN.swiper_css'))

配置手机 PC 页面白天黑夜共四个背景图

See:https://akilar.top/posts/23fdf850/

[Blogroot]\themes\butterfly\layout\includes\layout.pug 14~15 行

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
- var DefaultBg = page.defaultbg ? page.defaultbg : theme.background.default
- var DDMBg = theme.background.darkmode ? theme.background.darkmode : DefaultBg
- var DarkmodeBg = page.darkmodebg ? page.darkmodebg : DDMBg
if theme.background
#web_bg
if page.defaultbg || page.darkmodebg
style.
#web_bg{
background: #{DefaultBg} !important;
background-attachment: local!important;
background-position: center!important;
background-size: cover!important;
background-repeat: no-repeat!important;
}
[data-theme="dark"]
#web_bg{
background: #{DarkmodeBg} !important;
background-attachment: local!important;
background-position: center!important;
background-size: cover!important;
background-repeat: no-repeat!important;
}

新建 [Blogroot]\themes\butterfly\source\css\_layout\web-bg.styl

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
$web-bg-night = hexo-config('background.darkmode') ? unquote(hexo-config('background.darkmode')) : $web-bg
$mobile-bg-day = hexo-config('background.mobileday') ? unquote(hexo-config('background.mobileday')) : $web-bg
$mobile-bg-night = hexo-config('background.mobilenight') ? unquote(hexo-config('background.mobilenight')) : $web-bg-night
[data-theme="dark"]
#web_bg
background: $web-bg-night
background-attachment: local
background-position: center
background-size: cover
background-repeat: no-repeat
@media screen and (max-width: 800px)
#web_bg
background: $mobile-bg-day !important
background-attachment: local !important
background-position: center !important
background-size: cover !important
background-repeat: no-repeat !important
[data-theme="dark"]
#web_bg
background: $mobile-bg-night !important
background-attachment: local !important
background-position: center !important
background-size: cover !important
background-repeat: no-repeat !important

[Blogroot]\themes\butterfly\source\css\var.styl 34 行

1
2
3
4
  $text-line-height = 2
- $web-bg = hexo-config('background') && unquote(hexo-config('background'))
+ $web-bg = hexo-config('background.default') && unquote(hexo-config('background.default'))
$index_top_img_height = hexo-config('index_top_img_height') ? convert(hexo-config('index_top_img_height')) : 100vh

[Blogroot]\themes\butterfly\layout\includes\third-party\pjax.pug 6 行(新版已经被压缩成一行了)

1
2
3
4
5
6
7
8
9
10
11
  script(src=url_for(theme.CDN.pjax))
script.
let pjaxSelectors = [
'title',
'#config-diff',
'#body-wrap',
'#rightside-config-hide',
'#rightside-config-show',
+ '#web_bg',
'.js-pjax'
]

See:https://akilar.top/posts/8322f8e6/

[Blogroot]\themes\butterfly\layout\includes\post\post-copyright.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
if theme.post_copyright.enable && page.copyright !== false
- let author = page.copyright_author ? page.copyright_author : config.author
- let url = page.copyright_url ? page.copyright_url : page.permalink
- let license = page.license ? page.license : theme.post_copyright.license
- let license_url = page.license_url ? page.license_url : theme.post_copyright.license_url
.post-copyright
.post-copyright__title
span.post-copyright-info
h #[=page.title]
.post-copyright__type
span.post-copyright-info
a(href=url_for(url))= theme.post_copyright.decode ? decodeURI(url) : url
.post-copyright-m
.post-copyright-m-info
.post-copyright-a
h 作者
.post-copyright-cc-info
h=author
.post-copyright-c
h 发布于
.post-copyright-cc-info
h=date(page.date, config.date_format)
.post-copyright-u
h 更新于
.post-copyright-cc-info
h=date(page.updated, config.date_format)
.post-copyright-c
h 许可协议
.post-copyright-cc-info
a.icon(rel='noopener' target='_blank' title='Creative Commons' href='https://creativecommons.org/')
i.fab.fa-creative-commons
a(rel='noopener' target='_blank' title=license href=url_for(license_url))=license

[Blogroot]\themes\butterfly\source\css\_layout\post.styl 全部

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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
beautify()
headStyle(fontsize)
padding-left: unit(fontsize + 12, 'px')

&:before
margin-left: unit((-(fontsize + 6)), 'px')
font-size: unit(fontsize, 'px')

&:hover
padding-left: unit(fontsize + 18, 'px')

h1,
h2,
h3,
h4,
h5,
h6
transition: all .2s ease-out

&:before
position: absolute
top: calc(50% - 7px)
color: $title-prefix-icon-color
content: $title-prefix-icon
line-height: 1
transition: all .2s ease-out
@extend .fontawesomeIcon

&:hover
&:before
color: $light-blue

h1
headStyle(20)

h2
headStyle(18)

h3
headStyle(16)

h4
headStyle(14)

h5
headStyle(12)

h6
headStyle(12)

ol,
ul
p
margin: 0 0 8px

li
&::marker
color: $light-blue
font-weight: 600
font-size: 1.05em

&:hover
&::marker
color: var(--pseudo-hover)

ul > li
list-style-type: circle

#article-container
word-wrap: break-word
overflow-wrap: break-word

a
color: $theme-link-color

&:hover
text-decoration: underline

img
display: block
margin: 0 auto 20px
max-width: 100%
transition: filter 375ms ease-in .2s

p
margin: 0 0 16px

iframe
margin: 0 0 20px

if hexo-config('anchor')
a.headerlink
&:after
@extend .fontawesomeIcon
float: right
color: var(--headline-presudo)
content: '\f0c1'
font-size: .95em
opacity: 0
transition: all .3s

&:hover
&:after
color: var(--pseudo-hover)

h1,
h2,
h3,
h4,
h5,
h6
&:hover
a.headerlink
&:after
opacity: 1

ol,
ul
ol,
ul
padding-left: 20px

li
margin: 4px 0

p
margin: 0 0 8px

if hexo-config('beautify.enable')
if hexo-config('beautify.field') == 'site'
beautify()
else if hexo-config('beautify.field') == 'post'
&.post-content
beautify()

> :last-child
margin-bottom: 0 !important

#post
.tag_share
.post-meta
&__tag-list
display: inline-block

&__tags
display: inline-block
margin: 8px 8px 8px 0
padding: 0 12px
width: fit-content
border: 1px solid $light-blue
border-radius: 12px
color: $light-blue
font-size: .85em
transition: all .2s ease-in-out

&:hover
background: $light-blue
color: var(--white)

.post_share
display: inline-block
float: right
margin: 8px 0
width: fit-content

.social-share
font-size: .85em

.social-share-icon
margin: 0 4px
width: w = 1.85em
height: w
font-size: 1.2em
line-height: w

.post-copyright
position: relative
margin: 40px 0 10px
padding: 10px 16px
border: 1px solid var(--light-grey)
transition: box-shadow .3s ease-in-out
overflow: hidden
border-radius: 12px!important
background-color: rgb(239 241 243)

&:before
background var(--heo-post-blockquote-bg)
position absolute
right -26px
top -120px
content '\f25e'
font-size 200px
font-family 'Font Awesome 5 Brands'
opacity .2

&:hover
box-shadow: 0 0 8px 0 rgba(232, 237, 250, .6), 0 2px 4px 0 rgba(232, 237, 250, .5)

.post-copyright
&-meta
color: $light-blue
font-weight: bold

&-info
padding-left: 6px

a
text-decoration: none
word-break: break-word

&:hover
text-decoration: none

.post-copyright-cc-info
color: $theme-color;

.post-outdate-notice
position: relative
margin: 0 0 20px
padding: .5em 1.2em
border-radius: 3px
background-color: $noticeOutdate-bg
color: $noticeOutdate-color

if hexo-config('noticeOutdate.style') == 'flat'
padding: .5em 1em .5em 2.6em
border-left: 5px solid $noticeOutdate-border

&:before
@extend .fontawesomeIcon
position: absolute
top: 50%
left: .9em
color: $noticeOutdate-border
content: '\f071'
transform: translateY(-50%)

.ads-wrap
margin: 40px 0
.post-copyright-m-info
.post-copyright-a,
.post-copyright-c,
.post-copyright-u
display inline-block
width fit-content
padding 2px 5px
[data-theme="dark"]
#post
.post-copyright
background-color #07080a
text-shadow #bfbeb8 0 0 2px
border 1px solid rgb(19 18 18 / 35%)
box-shadow 0 0 5px rgb(20, 120, 210)
animation flashlight 1s linear infinite alternate
.post-copyright-info
color #e0e0e4

#post
.post-copyright__title
font-size 22px
.post-copyright__notice
font-size 15px
.post-copyright
box-shadow 2px 2px 5px

Butterfly comment board beautify

See:https://akilar.top/posts/397b8b90/

[Blogroot]\themes\butterfly\layout\includes\rightside.pug

1
2
3
  if commentsJsLoad
- a#to_comment(href="#post-comment" title=_p("rightside.scroll_to_comment"))
+ button#to_comment(type="button" title=_p("rightside.scroll_to_comment") onclick="FixedCommentBtn();")

新建 [Blogroot]\themes\butterfly\source\css\_layout\fixed_card_widget.styl

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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
// 垂直居中卡片样式(排除toc目录卡片)
.fixed-card-widget
&:not(#card-toc)
visibility visible!important
display block!important
position fixed!important
bottom 0
left 0
top 0
right 0
margin auto
margin-bottom auto!important
margin-top auto!important
max-width 300px
max-height 500px
width auto
height fit-content
z-index 999
animation rotateX 0.5s ease
animation-fill-mode forwards
// 针对说说卡片做样式兼容适配
.card-shuo
&.fixed-card-widget
#artitalk_main
max-height 460px
overflow scroll
&::-webkit-scrollbar
display: none
#operare_artitalk
.c2
z-index 1000
// 针对标签卡片做样式兼容适配
.card-tags
&.fixed-card-widget
.card-tag-cloud
max-height 460px
overflow scroll
&::-webkit-scrollbar
display: none
// 控制手机端可见
@media screen and (max-width: 768px)
div#fixedcard-dashboard
display flex!important
// 侧栏悬浮按钮样式
div#fixedcard-dashboard
position fixed
top 150px
width fit-content
height 40px
opacity 0.3
transition all 0.5s
display none
background rgba(255,255,255,0.9)
padding 5px 10px
border-top-right-radius 20px
border-bottom-right-radius 20px
z-index 1000
&:hover
opacity 1
button
&.fixedcard-activebtn
width 30px
opacity 1
pointer-events all
// 按钮样式
button
&.fixedcard-activebtn
width 0px
height 30px
transition all .5s
display flex
opacity 0
align-items center
justify-content space-around
pointer-events none
color #757273
// 悬浮按钮头像
.fixedcard-user-avatar
display inline-block
img
&.fixedcard-user-avatar-img
width 30px
height 30px
border-radius 50%
// 悬浮按钮夜间模式适配
[data-theme="dark"]
div#fixedcard-dashboard
background rgba(55,55,55,0.9)
button
&.fixedcard-activebtn
color #bcbdbd

// 卡片开启动画效果
@keyframes rotateX
from
transform rotateX(90deg)
to
transform rotateX(0deg)
// 退出蒙版效果
div#quit-box
position fixed
display block
left 0
top 0
width 100vh
height 100vh
z-index 99
background rgba(25,25,25,0.3)


[data-theme="dark"]
div#quit-box
background rgba(147, 146, 128, 0.3)

新建 [Blogroot]\themes\butterfly\layout\includes\fixed_card_widget.pug

1
2
3
4
5
6
7
8
9
10
11
#fixedcard-dashboard
if is_post()
each poitem in theme.fixed_card_widget.post
button.fixedcard-activebtn(type="button" title=poitem.title onclick=`FixedCardWidget("` + poitem.type + `","` + poitem.name + `","` + poitem.index + `")`)
i(class=poitem.icon)
else
each paitem in theme.fixed_card_widget.page
button.fixedcard-activebtn(type="button" title=paitem.title onclick=`FixedCardWidget("` + paitem.type + `","` + paitem.name + `","` + paitem.index + `")`)
i(class=paitem.icon)
.fixedcard-user-avatar.fixedcard-activebtn(onclick="RemoveFixedCardWidget()")
img.fixedcard-user-avatar-img(src=url_for(theme.avatar.img) title=config.author)

[Blogroot]\themes\butterfly\layout\includes\additional-js.pug 末尾

1
2
3
4
  if theme.busuanzi.site_uv || theme.busuanzi.site_pv || theme.busuanzi.page_pv
script(async data-pjax src=url_for(theme.CDN.busuanzi))
+ if !theme.aside.mobile && theme.fixed_card_widget.enable
+ include ./fixed_card_widget.pug

[Blogroot]\themes\butterfly\layout\includes\third-party\pjax.pug 6 行

1
2
3
4
5
6
7
8
9
10
  script.
let pjaxSelectors = [
'title',
'#config-diff',
'#body-wrap',
'#rightside-config-hide',
'#rightside-config-show',
+ '#fixedcard-dashboard',
'.js-pjax'
]

导航栏魔改

[Blogroot]\themes\butterfly\layout\includes\header\nav.pug 全部

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
nav#nav
span#blog_name
a#site-name(href=url_for('/')) #[=config.title]

#menus
!=partial('includes/header/menu_item', {}, {cache: true})
#nav-right
if (theme.algolia_search.enable || theme.local_search.enable)
#search-button
a.site-page.social-icon.search
i.fas.fa-search.fa-fw
span=' '+_p('search.title')
#darkmode_navswitch
a.nav-rightbutton.site-page.darkmode_switchbutton(onclick='switchNightMode()', title=_p('rightside.night_mode_title'))
i.fas.fa-adjust

#toggle-menu
a.site-page
i.fas.fa-bars.fa-fw