From 666637ce9915c53716d0005cd616fe6740282b12 Mon Sep 17 00:00:00 2001 From: Jerry Date: Thu, 15 Oct 2020 14:39:51 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=80=80=E5=9B=9E=E4=B9=8B=E5=89=8D?= =?UTF-8?q?=E7=9A=84inject=E5=AF=A6=E7=8F=BE,=E8=A7=A3=E6=B1=BA=E4=B8=8A?= =?UTF-8?q?=E4=B8=80=E5=80=8B=E7=89=88=E6=9C=AC=E5=B0=8E=E8=87=B4=E7=84=A1?= =?UTF-8?q?=E6=B3=95=E6=8F=92=E5=85=A5inject=E7=9A=84bugs=20close=20#390?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- layout/includes/additional-js.pug | 4 +++- layout/includes/head.pug | 1 + package.json | 2 +- scripts/helpers/page.js | 9 +++++++++ scripts/injector/inject.js | 22 ---------------------- 5 files changed, 14 insertions(+), 24 deletions(-) delete mode 100644 scripts/injector/inject.js 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 -}