diff --git a/layout/_layout.pug b/layout/_layout.pug index caed7a4c2fcad2bcaf3ce9470e574e5f1381d372..d6ad266ab9463f6e6711588ecf4ce09ff0374f76 100644 --- a/layout/_layout.pug +++ b/layout/_layout.pug @@ -14,7 +14,10 @@ html(lang=config.language) body div#container.container header#header.header - div.header-inner + div.header-inner(style=`${ + theme.header.bg_image.enable && + page.top_image ? 'background: url(' + page.top_image + ') no-repeat center/cover;' : '' + }`) != partial('./_partials/header/header.pug', null, { cache: theme.cache }) main#main.main diff --git a/layout/_third-party/pjax.pug b/layout/_third-party/pjax.pug index 696903dff520fbaf5afc1a99370c0ee32166642f..4c2cd6694c474051bc7b43d519204be699f7e74e 100644 --- a/layout/_third-party/pjax.pug +++ b/layout/_third-party/pjax.pug @@ -1,10 +1,16 @@ - + var pjaxSelectors = [ + 'head title', + '#main', + '.pjax-reload' + ]; + + if (theme.header.bg_image.enable) { + pjaxSelectors.push('.header-inner'); + } + var pjaxArgs = { - 'selectors': [ - 'head title', - '#main', - '.pjax-reload' - ], + 'selectors': pjaxSelectors, 'history': theme.pjax.history, 'scrollTo': theme.pjax.scrollTo, 'scrollRestoration': theme.pjax.scrollRestoration, diff --git a/source/css/_common/components/header/index.styl b/source/css/_common/components/header/index.styl index d3f0d953a983f052b5794e5294713a6bcdd43169..47f61b7373a0340695491a345ff3cf078a29a85a 100644 --- a/source/css/_common/components/header/index.styl +++ b/source/css/_common/components/header/index.styl @@ -9,10 +9,7 @@ height: convert(hexo-config('header.height') || '80vh'); } - if (hexo-config('page.top_image')) { - background: url(hexo-config('page.top_image')) no-repeat center center; - background-size: cover; - } else if (hexo-config('header.bg_image.enable')) { + if (hexo-config('header.bg_image.enable')) { background: url(hexo-config('header.bg_image.url')) no-repeat center center; background-size: cover; }