hexo-theme-butterfly/scripts/tag/note.js
Jerry 931a0ba82d breaking changes: archives 隱藏 aside 設置更改
feat: tag 和 category 頁面可設置隱藏 aside
feat: 子歸檔頁面顯示的文章數量不再顯示總文章數量,而是對應的子歸檔文章數量
feat: 為一些數據加載增加 loading 顯示
improvement: 修改 note 圖標 class 名字,避免第三方圖標覆蓋主題樣式
2022-06-17 01:01:46 +08:00

28 lines
813 B
JavaScript

/**
* note.js
* transplant from hexo-theme-next
* Modify by Jerry
*/
'use strict'
function postNote (args, content) {
const styleConfig = hexo.theme.config.note.style
const lastArgs = args[args.length - 1]
if (!(lastArgs === 'flat' || lastArgs === 'modern' || lastArgs === 'simple' || lastArgs === 'disabled')) {
args.push(styleConfig)
}
let icon = ''
const iconArray = args[args.length - 2]
if (iconArray && iconArray.startsWith('fa')) {
icon = `<i class="note-icon ${iconArray}"></i>`
args[args.length - 2] = 'icon-padding'
}
return `<div class="note ${args.join(' ')}">${icon + hexo.render.renderSync({ text: content, engine: 'markdown' })}</div>`
}
hexo.extend.tag.register('note', postNote, { ends: true })
hexo.extend.tag.register('subnote', postNote, { ends: true })