环境
Butterfly 版本:4.3.1
放入视频文件 spring.mp4
到 [blogRoot]/source/temp/
_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_top_img: false
index_img: /temp/spring.mp4
default_top_img: false
archive_img: false
tag_img: false
tag_per_img: false
category_img: false
category_per_img: false
|
代码
编辑 [themeRoot]/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=''
内改为你的视频文件地址。