diff --git a/layout/includes/head/config.pug b/layout/includes/head/config.pug index 3ad380a..61c26ea 100644 --- a/layout/includes/head/config.pug +++ b/layout/includes/head/config.pug @@ -88,6 +88,7 @@ script. var GLOBAL_CONFIG = { root: '!{config.root}', + hexoversion: '!{get_hexo_version()}', algolia: !{algolia}, localSearch: !{localSearch}, translate: !{translate}, diff --git a/layout/includes/third-party/pjax.pug b/layout/includes/third-party/pjax.pug index b15b058..a8ff1d1 100644 --- a/layout/includes/third-party/pjax.pug +++ b/layout/includes/third-party/pjax.pug @@ -1,16 +1,22 @@ script(src=url_for(theme.CDN.pjax)) script. - var pjax = new Pjax({ + let pjaxSelectors = [ + 'title', + 'meta[name=description]', + '#config_change', + '#body-wrap', + '#rightside-config-hide', + '#rightside-config-show', + '.js-pjax' + ] + + if (!{theme.Open_Graph_meta && theme.comments.use && theme.comments.use.includes('Livere')}) { + pjaxSelectors.unshift('meta[property="og:image"]', 'meta[property="og:title"]', 'meta[property="og:url"]') + } + + const pjax = new Pjax({ elements: 'a:not([target="_blank"])', - selectors: [ - 'title', - 'meta[name=description]', - '#config_change', - '#body-wrap', - '#rightside-config-hide', - '#rightside-config-show', - '.js-pjax' - ], + selectors: pjaxSelectors, cacheBust: false, }) diff --git a/package.json b/package.json index c8bac68..53ee22c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hexo-theme-butterfly", - "version": "3.0.0", + "version": "3.0.1", "description": "A Simple and Card UI Design theme for Hexo", "main": "package.json", "scripts": { diff --git a/scripts/helpers/page.js b/scripts/helpers/page.js index f827ccf..87d13b5 100644 --- a/scripts/helpers/page.js +++ b/scripts/helpers/page.js @@ -61,3 +61,7 @@ hexo.extend.helper.register('urlNoIndex', function () { hexo.extend.helper.register('md5', function (path) { return crypto.createHash('md5').update(decodeURI(this.url_for(path))).digest('hex') }) + +hexo.extend.helper.register('get_hexo_version', function () { + return hexo.version +}) \ No newline at end of file diff --git a/source/css/_global/index.styl b/source/css/_global/index.styl index 4877bc4..8de27f3 100644 --- a/source/css/_global/index.styl +++ b/source/css/_global/index.styl @@ -249,7 +249,7 @@ if hexo-config('avatar.effect') == true for i in 1 2 3 4 > :nth-child({i}) - animation: sidebarItem (i / 5) s + animation: sidebarItem (i / 5)s @keyframes scroll-down-effect 0% diff --git a/source/js/main.js b/source/js/main.js index 5bcbe45..8fcd473 100644 --- a/source/js/main.js +++ b/source/js/main.js @@ -465,6 +465,7 @@ const tocFn = function () { // DOM Hierarchy: // ol.toc > (li.toc-item, ...) // li.toc-item > (a.toc-link, ol.toc-2child > (li.toc-item, ...)) + const versionBiggerFive = GLOBAL_CONFIG.hexoversion.split('.')[0] >= 5 const findHeadPosition = function (top) { // assume that we are not in the post page if no TOC link be found, // thus no need to update the status @@ -477,7 +478,8 @@ const tocFn = function () { list.each(function () { const head = $(this) if (top > head.offset().top - 25) { - currentId = '#' + encodeURI($(this).attr('id')) + if (versionBiggerFive) currentId = '#' + encodeURI($(this).attr('id')) + else currentId = '#' + $(this).attr('id') } })