环境

Butterfly 版本:4.3.1

进入 Hexo 目录,放入视频文件并编辑配置文件:

_config.butterfly.yml
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
# Disable all banner image
disable_top_img: false

# The banner image of home page
index_img: /temp/spring.mp4 # 随便填

# If the banner of page not setting, it will show the top_img
default_top_img: false

# The banner image of archive page
archive_img: false

# If the banner of tag page not setting, it will show the top_img
# note: tag page, not tags page (子標籤頁面的 top_img)
tag_img: false

# The banner image of tag page
# format:
# - tag name: xxxxx
tag_per_img: false

# If the banner of category page not setting, it will show the top_img
# note: category page, not categories page (子分類頁面的 top_img)
category_img: false

# The banner image of category page
# format:
# - category name: xxxxx
category_per_img: false

代码

进入主题目录

[btf]/layout/includes/header/index.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
if !theme.disable_top_img && page.top_img !== false
if is_post()
- var top_img = false
else if is_page()
- var top_img = page.top_img || theme.default_top_img
else if is_tag()
- var top_img = theme.tag_per_img && theme.tag_per_img[page.tag]
- top_img = top_img ? top_img : (theme.tag_img !== false ? theme.tag_img || theme.default_top_img : false)
else if is_category()
- var top_img = theme.category_per_img && theme.category_per_img[page.category]
- top_img = top_img ? top_img : (theme.category_img !== false ? theme.category_img || theme.default_top_img : false)
else if is_home()
- var top_img = theme.index_img !== false ? theme.index_img || theme.default_top_img : false
else if is_archive()
- var top_img = theme.archive_img !== false ? theme.archive_img || theme.default_top_img : false
else
- var top_img = page.top_img || theme.default_top_img

if top_img !== false
- var site_title = page.title || page.tag || page.category || config.title
- var isHomeClass = is_home() ? 'full_page' : 'not-home-page'
- is_post() ? isHomeClass = 'post-bg' : isHomeClass
else
- var isHomeClass = 'not-top-img'
else
- var top_img = false
- var isHomeClass = 'not-top-img'

header#page-header(class=isHomeClass)
!=partial('includes/header/nav', {}, {cache: true})
if top_img !== false
if is_post()
- var isHomeClass = 'not-top-img'
include ./post-info.pug
else if is_home()
video(src='/temp/spring.mp4' autoplay="" loop="" muted="" style='min-height:100%;height:100%;width:100%;object-fit:cover')
#site-info
h1#site-title=site_title
if theme.subtitle.enable
- var loadSubJs = true
#site-subtitle
span#subtitle
if(theme.social)
#site_social_icons
!=fragment_cache('social', function(){return partial('includes/header/social')})
#scroll-down
i.fas.fa-angle-down.scroll-down-effects
else
#page-site-info
h1#site-title=site_title

请对照原版代码,我删除了 if top_img !== false 下的两行并对后文做了相应修改。上方第 3、33 行控制文章页不显示头图。

还需要修改第 36 行,将 src='' 内改为你的视频文件地址。