💥 改cdn_use為inject,可插入代碼到head或者bottom

💥 移除對文章隱藏的支持,如需要,請使用插件,hexo-hide-posts/hexo-generator-indexed
💥 移除subtitle金山詞霸每日一句,增加搏天api的隨機語錄
 subtitle修改為網頁加載完後再加載,防止api回應過慢而阻礙網頁顯示
 適配valine 1.4.0, 刪除部分valine夜間模式代碼
 meta增加article:published_time和article:modified_time
 當沒有設置Description時,會自動讀取文章前200個文字作為meta Description
 sidebar menu 增加頭像轉圈hover
💄 調整aside和mobile sidebar 網頁資訊佈局,當缺少一個時,寬度依舊平分
🐛 調整子目錄的排版(向左對齊),修復只能點擊子目錄文字才能跳轉的bug
🔥 pug精簡 刪除recent-post.pug  改為引用mixins/post-ui.pug
This commit is contained in:
Jerry
2020-04-12 02:40:54 +08:00
Unverified
parent e81a81c9d1
commit d62ec1b866
29 changed files with 223 additions and 369 deletions
-66
View File
@@ -1,66 +0,0 @@
/**
* global hexo
* from printempw/hexo-hide-posts
* modify by Jerry
*/
'use strict'
var public_generators = []
hexo.extend.filter.register('before_generate', function () {
this._bindLocals()
const all_posts = this.locals.get('posts')
const hidden_posts = all_posts.find({
hide: true
})
const normal_posts = all_posts.filter(post => !post.hide)
this.locals.set('all_posts', all_posts)
this.locals.set('hidden_posts', hidden_posts)
this.locals.set('posts', normal_posts)
})
hexo.extend.filter.register('after_init', function () {
const original = {}
for (const name in hexo.extend.generator.list()) {
original[name] = hexo.extend.generator.get(name)
}
hexo.extend.generator.register('post', async function (locals) {
const fg = original.post.bind(this)
const generated_public = await fg(locals)
const generated_hidden = await fg(
Object.assign({}, locals, {
posts: locals.hidden_posts
})
)
// Remove post.prev and post.next for hidden posts
generated_hidden.forEach(ele => {
ele.data.prev = ele.data.next = null
})
return generated_public.concat(generated_hidden)
})
// Then we hack into other generators if necessary
public_generators
.filter(name => Object.keys(original).includes(name))
.forEach(name => {
// Overwrite original generator
hexo.extend.generator.register(name, function (locals) {
const fg = original[name].bind(this)
return fg(
Object.assign({}, locals, {
posts: new locals.posts.constructor(
locals.posts.data.concat(locals.hidden_posts.data)
)
})
)
})
})
})
-24
View File
@@ -1,24 +0,0 @@
/**
* Butterfly
* Generate js and css according to user setting
*/
'use strict'
hexo.extend.helper.register('my_html', function (type, data) {
var result = ''
var tag = type === 'css' ? 'css' : 'script'
for (var i = 0; i < data.length; i++) {
var src = data[i].split('||')[0].trim()
var other = data[i].split('||')[1] ? data[i].split('||')[1].trim() : ''
if (tag === 'css') {
result +=
'<link rel="stylesheet" href="' + this.url_for(src) + '" ' + other + '>'
} else {
result +=
'<script src="' + this.url_for(src) + '" ' + other + '></script>'
}
}
return result
})
+31
View File
@@ -0,0 +1,31 @@
/**
* Butterfly
* @example
* page_description()
* injectHtml(data)
*/
'use strict'
const { stripHTML } = require('hexo-util')
hexo.extend.helper.register('page_description', function () {
const { config, page } = this
let description = page.description || page.excerpt || page.content || page.title || config.description
if (description) {
description = stripHTML(description).substring(0, 200)
.trim()
.replace(/\n/g, ' ')
return description
}
})
hexo.extend.helper.register('injectHtml', function (data) {
let result = ''
if (!data) return ''
for (var i = 0; i < data.length; i++) {
result += data[i]
}
return result
})
+1
View File
@@ -1,5 +1,6 @@
/**
* Butterfly
* @example
* hideInline
* {% hideInline content,display,bg,color %}
* content不能包含當引號,可用 &apos;