feat: 增加標籤外掛 tag-toggle

 feat: 增加頁面加載動畫preloader close #193
 feat: 適配hexo-generator-indexed插件
 feat: aside subtitle可配置,優先顯示配置內容、沒有的顯示頁面subtitle close #191
 feat: aside card-tags可配置是否顯示顏色
 feat: algolia-search highligh文字加深
 feat: 增加頁面keywords設置 #191
 feat: darkmode和readmode配色微調
🐛 fix: 修復hide-block 配置顏色顯示出錯的bug
🐛 fix: 修正zh-TW部分用語
This commit is contained in:
Jerry
2020-04-17 19:48:07 +08:00
Unverified
parent d62ec1b866
commit b512eb761d
36 changed files with 541 additions and 255 deletions
+14 -1
View File
@@ -3,6 +3,7 @@
* @example
* page_description()
* injectHtml(data)
* cloudTags(source, minfontsize, maxfontsize, limit)
*/
'use strict'
@@ -11,7 +12,7 @@ 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
let description = page.description || page.content || page.title || config.description
if (description) {
description = stripHTML(description).substring(0, 200)
@@ -29,3 +30,15 @@ hexo.extend.helper.register('injectHtml', function (data) {
}
return result
})
hexo.extend.helper.register('cloudTags', function (source, minfontsize, maxfontsize, limit) {
const env = this
let result = ''
const tagLimit = limit === 0 ? source.length : limit
source.sort('name').limit(tagLimit).forEach(function (tags) {
var fontSize = Math.floor(Math.random() * (maxfontsize - minfontsize) + minfontsize) + 'px'
var color = 'rgb(' + Math.floor(Math.random() * 201) + ', ' + Math.floor(Math.random() * 201) + ', ' + Math.floor(Math.random() * 201) + ')' // 0,0,0 -> 200,200,200
result += `<a href='${env.url_for(tags.path)}' style='font-size:${fontSize}; color:${color}'>${tags.name}</a>`
})
return result
})
+45 -10
View File
@@ -8,29 +8,64 @@
* {% hideBlock display,bg,color %}
* content
* {% endhideBlock %}
* hideToggle
* {% hideToggle display,bg,color %}
* content
* {% endhideToggle %}
*/
'use strict'
function hideInline (args) {
args = args.join(' ').split(',')
const content = args[0].trim()
const display = args[1] || 'Click'
const bg = args[2] === '' || typeof args[2] === 'undefined' ? '' : `background-color:${args[2]}`
const color = args[3] || '#fff'
return `<span class="hide-inline"><a class="hide-button button--primary button--animated" style="color:${color};${bg}">${display}
</a><span class="hide-content">${content}</span></span>`
var content = args[0]
var display = args[1] || 'Click'
var bg = args[2] || false
var color = args[3] || false
var group = 'style="'
if (bg) group += `background-color: ${bg};`
if (color) group += `color: ${color}`
group += '"'
return `<span class="hide-inline"><a class="hide-button button--primary button--animated" ${group}>${display}
</a><span class="hide-content">${content}</span></span>`
}
function hideBlock (args, content) {
args = args.join(' ').split(',')
const display = args[0] || 'Click'
const bg = args[1] === '' || typeof args[2] === 'undefined' ? '' : `background-color:${args[2]}`
const color = args[2] || '#fff'
var display = args[0] || 'Click'
var bg = args[1] || false
var color = args[2] || false
var group = 'style="'
return `<div class="hide-block"><a class="hide-button button--primary button--animated" style="color:${color};${bg}">${display}
if (bg) group += `background-color: ${bg};`
if (color) group += `color: ${color}`
group += '"'
return `<div class="hide-block"><a class="hide-button button--primary button--animated" ${group}>${display}
</a><span class="hide-content">${hexo.render.renderSync({ text: content, engine: 'markdown' }).split('\n').join('')}</span></div>`
}
function hideToggle (args, content) {
args = args.join(' ').split(',')
var display = args[0]
var bg = args[1] || false
var color = args[2] || false
var group = 'style="'
var border = ''
if (bg) {
border = `style="border: 1px solid ${bg}"`
group += `background-color: ${bg};`
}
if (color) group += `color: ${color}`
group += '"'
return `<div class="hide-toggle" ${border}><div class="hide-button toggle-title" ${group}><i class="fa fa-caret-right fa-fw"></i><span>${display}</span></div>
<div class="hide-content">${hexo.render.renderSync({ text: content, engine: 'markdown' }).split('\n').join('')}</div></div>`
}
hexo.extend.tag.register('hideInline', hideInline)
hexo.extend.tag.register('hideBlock', hideBlock, { ends: true })
hexo.extend.tag.register('hideToggle', hideToggle, { ends: true })