mirror of
https://github.com/jerryc127/hexo-theme-butterfly.git
synced 2026-08-08 19:48:42 +08:00
chore: v5.7.0
- Remove APlayer/Meting music player support - Upgrade Artalk to 2.10.0 and add vote feature - Cache plugins.yml to avoid re-rendering on every generate - Add null safety for error_404 and highlight config - Fix series date timestamp format - Enhance shuoshuo mockPost compatibility and error handling - Prevent scrollbar flicker when fancybox is open - Update plugin versions (docsearch, katex, twikoo) - Bump version to 5.7.0
This commit is contained in:
@@ -378,6 +378,7 @@ module.exports = {
|
||||
server: null,
|
||||
site: null,
|
||||
visitor: false,
|
||||
vote: false,
|
||||
option: null
|
||||
},
|
||||
chat: {
|
||||
@@ -555,10 +556,6 @@ module.exports = {
|
||||
enable: false,
|
||||
exclude: null
|
||||
},
|
||||
aplayerInject: {
|
||||
enable: false,
|
||||
per_page: true
|
||||
},
|
||||
snackbar: {
|
||||
enable: false,
|
||||
position: 'bottom-left',
|
||||
|
||||
@@ -6,7 +6,8 @@
|
||||
'use strict'
|
||||
|
||||
hexo.extend.generator.register('404', function (locals) {
|
||||
if (!hexo.theme.config.error_404.enable) return
|
||||
const error404 = hexo.theme.config.error_404 || {}
|
||||
if (!error404.enable) return
|
||||
return {
|
||||
path: '404.html',
|
||||
layout: ['page'],
|
||||
|
||||
@@ -8,11 +8,19 @@
|
||||
const { version } = require('../../package.json')
|
||||
const path = require('path')
|
||||
|
||||
// Cache plugins.yml to avoid re-rendering on every generate
|
||||
let cachedPlugins = null
|
||||
const loadPlugins = hexo => {
|
||||
if (cachedPlugins) return cachedPlugins
|
||||
cachedPlugins = hexo.render.renderSync({ path: path.join(hexo.theme_dir, '/plugins.yml'), engine: 'yaml' })
|
||||
return cachedPlugins
|
||||
}
|
||||
|
||||
hexo.extend.filter.register('before_generate', () => {
|
||||
const themeConfig = hexo.theme.config
|
||||
const { CDN } = themeConfig
|
||||
|
||||
const thirdPartySrc = hexo.render.renderSync({ path: path.join(hexo.theme_dir, '/plugins.yml'), engine: 'yaml' })
|
||||
const thirdPartySrc = loadPlugins(hexo)
|
||||
const internalSrc = {
|
||||
main: {
|
||||
name: 'hexo-theme-butterfly',
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
'use strict'
|
||||
|
||||
hexo.extend.filter.register('stylus:renderer', style => {
|
||||
const { syntax_highlighter: syntaxHighlighter, highlight, prismjs } = hexo.config
|
||||
const { syntax_highlighter: syntaxHighlighter, highlight = {}, prismjs = {} } = hexo.config
|
||||
let { enable: highlightEnable, line_number: highlightLineNumber } = highlight
|
||||
let { enable: prismjsEnable, line_number: prismjsLineNumber } = prismjs
|
||||
|
||||
|
||||
@@ -69,18 +69,14 @@ hexo.extend.helper.register('aside_archives', function (options = {}) {
|
||||
|
||||
// Use template literal for better readability
|
||||
const archiveHeader = `
|
||||
<div class="item-headline">
|
||||
<i class="fas fa-archive"></i>
|
||||
<span>${_p('aside.card_archives')}</span>
|
||||
${
|
||||
data.length > limitedData.length
|
||||
? `<a class="card-more-btn" href="${urlFor(archiveDir)}/"
|
||||
<div class="item-headline"><i class="fas fa-archive"></i><span>${_p('aside.card_archives')}</span>${
|
||||
data.length > limitedData.length
|
||||
? `<a class="card-more-btn" href="${urlFor(archiveDir)}/"
|
||||
title="${_p('aside.more_button')}">
|
||||
<i class="fas fa-angle-right"></i>
|
||||
</a>`
|
||||
: ''
|
||||
}
|
||||
</div>
|
||||
: ''
|
||||
}</div>
|
||||
`
|
||||
|
||||
// Use map for generating list items, join for performance
|
||||
|
||||
@@ -89,11 +89,7 @@ hexo.extend.helper.register('aside_categories', function (categories, options =
|
||||
<i class="fas fa-angle-right"></i></a>`
|
||||
: ''
|
||||
|
||||
return `<div class="item-headline">
|
||||
<i class="fas fa-folder-open"></i>
|
||||
<span>${this._p('aside.card_categories')}</span>
|
||||
${moreButton}
|
||||
</div>
|
||||
return `<div class="item-headline"><i class="fas fa-folder-open"></i><span>${this._p('aside.card_categories')}</span>${moreButton}</div>
|
||||
<ul class="card-category-list${isExpand && list.result ? ' expandBtn' : ''}" id="aside-cat-list">
|
||||
${list.result}
|
||||
</ul>`
|
||||
|
||||
+15
-2
@@ -159,8 +159,21 @@ hexo.extend.helper.register('shuoshuoFN', (data, page) => {
|
||||
item.date = moment.tz(parsed.format('YYYY-MM-DD HH:mm:ss'), timezone).format('YYYY-MM-DD HH:mm:ss')
|
||||
|
||||
// Render the content using Hexo's rendering engine to process any tags or markdown
|
||||
const mockPost = { content: item.content }
|
||||
hexo.execFilterSync('before_post_render', mockPost, { context: hexo })
|
||||
const mockPost = {
|
||||
content: item.content,
|
||||
source: item.source || page.source || '',
|
||||
full_source: page.full_source || '',
|
||||
path: page.path || '',
|
||||
layout: item.layout || page.layout || 'post',
|
||||
raw: item.raw || item.content,
|
||||
draft: false,
|
||||
published: true
|
||||
}
|
||||
try {
|
||||
hexo.execFilterSync('before_post_render', mockPost, { context: hexo })
|
||||
} catch (e) {
|
||||
// ignore third-party plugin errors, fallback to markdown-only rendering
|
||||
}
|
||||
item.content = mockPost.content
|
||||
|
||||
const codeBlocks = []
|
||||
|
||||
@@ -23,7 +23,7 @@ function buildSeriesGroups () {
|
||||
groups[p.series].push({
|
||||
title: p.title,
|
||||
path: p.path,
|
||||
date: p.date.unix()
|
||||
date: p.date.valueOf()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user