Skip to content

Commit

Permalink
fix: Compatible with pjax when header are not enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
liuyib committed Feb 6, 2020
1 parent 74f251f commit 8302d30
Show file tree
Hide file tree
Showing 9 changed files with 415 additions and 388 deletions.
1 change: 1 addition & 0 deletions layout/_layout.pug
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
var STUN_URL = "https://github.com/liuyib/hexo-theme-stun/";
var faPrefix = theme.fa_prefix || 'fa';
var isNoHeader = !_.get(theme, 'header.enable') || (is_post() && !_.get(theme, 'header.show_on.post'));
var isEnableNoHeader = !_.get(theme, 'header.enable') || !_.get(theme, 'header.show_on.post');
var pjax = false;
var dataPjax = {};
Expand Down
29 changes: 14 additions & 15 deletions layout/_partials/header/header.pug
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
include ../../_mixins/menu-item.pug

nav.header-nav(class=`${isNoHeader ? '' : 'header-nav--fixed'}`)
nav.header-nav(class=`${isNoHeader ? 'header-nav--sticky' : 'header-nav--fixed'}`)
div.header-nav-inner
div.header-nav-btn(class=`${faPrefix} fa-bars`)
div.header-nav-menu
Expand All @@ -18,18 +18,17 @@ nav.header-nav(class=`${isNoHeader ? '' : 'header-nav--fixed'}`)
include ../widgets/night-mode.pug

if !isNoHeader
if _.get(theme, 'header.enable')
div.header-info(
style=`${
(_.get(theme, 'header.bg_image.enable') && page.top_image)
? 'background: url(' + page.top_image + ') no-repeat center/cover;'
: ''
}`
)
div.header-info-inner
div.header-info-title= config.title
div.header-info-subtitle= config.subtitle
div.header-info(
style=`${
(_.get(theme, 'header.bg_image.enable') && page.top_image)
? 'background: url(' + page.top_image + ') no-repeat center/cover;'
: ''
}`
)
div.header-info-inner
div.header-info-title= config.title
div.header-info-subtitle= config.subtitle

if _.get(theme, 'header.scroll_down_icon.enable')
div.header-info-arrow
i.fa.fa-angle-down.header-info-arrow__icon
if _.get(theme, 'header.scroll_down_icon.enable')
div.header-info-arrow
i.fa.fa-angle-down.header-info-arrow__icon
16 changes: 12 additions & 4 deletions layout/_third-party/pjax.pug
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
'#main',
'.pjax-reload'
];
if (_.get(theme, 'header.enable')) {
if (isEnableNoHeader) {
pjaxSelectors.push('.header-inner');
}
var pjaxArgs = {
Expand Down Expand Up @@ -88,11 +88,19 @@ script.
if (Stun.utils.pjaxReloadScroll) {
Stun.utils.pjaxReloadScroll();
}
if (Stun.utils.pjaxReloadHeader) {
Stun.utils.pjaxReloadHeader();
}
if (Stun.utils.pjaxReloadSidebar) {
Stun.utils.pjaxReloadSidebar();
}
if (!{ isEnableNoHeader }) {
if (Stun.utils.pjaxReloadHeader) {
Stun.utils.pjaxReloadHeader();
}
if (Stun.utils.pjaxReloadScrollIcon) {
Stun.utils.pjaxReloadScrollIcon();
}
if (Stun.utils.pjaxReloadLocalSearch) {
Stun.utils.pjaxReloadLocalSearch();
}
}
}, false);
}, false);

0 comments on commit 8302d30

Please sign in to comment.