diff --git a/layout/includes/additional-js.pug b/layout/includes/additional-js.pug index 9e6c8bf..1b62c05 100644 --- a/layout/includes/additional-js.pug +++ b/layout/includes/additional-js.pug @@ -55,10 +55,12 @@ div else if (!is_post() && page.aside !== false) !=partial('includes/third-party/newest-comments/index', {}, {cache:theme.fragment_cache}) + !=fragment_cache('injectBottom', function(){return injectHtml(theme.inject.bottom)}) + !=partial('includes/third-party/effect', {}, {cache:theme.fragment_cache}) !=partial('includes/third-party/chat/index', {}, {cache:theme.fragment_cache}) - + if theme.aplayerInject && theme.aplayerInject.enable if theme.pjax.enable || theme.aplayerInject.per_page include ./head/aplayer.pug diff --git a/layout/includes/head.pug b/layout/includes/head.pug index 62d0db5..cc5fff5 100644 --- a/layout/includes/head.pug +++ b/layout/includes/head.pug @@ -81,3 +81,4 @@ include ./head/noscript.pug !=partial('includes/head/darkmode', {}, {cache:theme.fragment_cache}) +!=fragment_cache('injectHead', function(){return injectHtml(theme.inject.head)}) \ No newline at end of file diff --git a/package.json b/package.json index 49010f2..ec6fef4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hexo-theme-butterfly", - "version": "3.3.0-b3", + "version": "3.3.0-b4", "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 270c166..fd44158 100644 --- a/scripts/helpers/page.js +++ b/scripts/helpers/page.js @@ -61,3 +61,12 @@ 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('injectHtml', function (data) { + let result = '' + if (!data) return '' + for (let i = 0; i < data.length; i++) { + result += data[i] + } + return result +}) diff --git a/scripts/injector/inject.js b/scripts/injector/inject.js deleted file mode 100644 index 069223e..0000000 --- a/scripts/injector/inject.js +++ /dev/null @@ -1,22 +0,0 @@ -// Injector - -'use strict' - -hexo.extend.injector.register('head_end', function () { - const data = hexo.config.theme_config && hexo.config.theme_config.inject.head - return genResult(data) -}) - -hexo.extend.injector.register('body_end', () => { - const data = hexo.config.theme_config && hexo.config.theme_config.inject.bottom - return genResult(data) -}) - -function genResult (data) { - let result = '' - if (!data) return '' - for (let i = 0; i < data.length; i++) { - result += data[i] - } - return result -}