fix: 退回之前的inject實現,解決上一個版本導致無法插入inject的bugs close #390

This commit is contained in:
Jerry 2020-10-15 14:39:51 +08:00
parent 8014ddb65e
commit 666637ce99
5 changed files with 14 additions and 24 deletions

View File

@ -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

View File

@ -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)})

View File

@ -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": {

View File

@ -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
})

View File

@ -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
}