chore: 升級版本至 5.5.2 並更新相依套件

- perf(highlight): 改善複製提示 UI,新增浮動動畫效果
- fix(shuoshuo): 為說說內容中的圖片新增延遲載入支援
- fix(mermaid): 支援在標籤助手中使用自訂配置選項
- fix: 使用 url_for() 處理主題資源路徑 (busuanzi, artalk)
- refactor(aside_archives): 重新命名 url_for 變數以保持一致性
- refactor(inject_head_js): 使用解構賦值命名方式
- chore(deps): 更新 hexo-util 至 4.0.0
- chore(plugins): 更新多個 CDN 套件版本
- style(highlight): 優化程式碼區塊工具列佈局與溢位處理
- fix(zh-CN): 修正分頁文字使用正確的簡體字「页」
This commit is contained in:
Jerry
2025-11-07 22:19:16 +08:00
parent 2d4765202d
commit 439014bbb6
11 changed files with 125 additions and 52 deletions

View File

@@ -52,7 +52,7 @@ div
!= partial("includes/third-party/umami_analytics", {}, { cache: true })
if theme.busuanzi.site_uv || theme.busuanzi.site_pv || theme.busuanzi.page_pv
script(async data-pjax src= theme.asset.busuanzi || '//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js')
script(async data-pjax src=url_for(theme.asset.busuanzi) || '//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js')
!= partial('includes/third-party/search/index', {}, { cache: true })

View File

@@ -49,6 +49,7 @@
if !page.shuoshuo_url
script(type='application/json' id='shuoshuo-data')!= safeJSON(localDate)
- const { enable, native, placeholder, field } = theme.lazyload
script.
(() => {
const limitConfig = !{ JSON.stringify(page.limit || {}) }
@@ -84,6 +85,36 @@
return `${year}-${month}-${day} ${hour}:${minute}:${second}`
}
const addLazyload = str => {
const config = {
enable: !{Boolean(enable)},
native: !{Boolean(native)},
field: '!{field}',
placeholder: '!{url_for(placeholder)}',
}
if (!config.enable || config.field !== 'site') return str
const parser = new DOMParser()
const doc = parser.parseFromString(str, 'text/html')
const images = doc.querySelectorAll('img')
images.forEach(img => {
if (config.native) {
img.setAttribute('loading', 'lazy')
} else {
const src = img.getAttribute('src')
img.setAttribute('data-lazy-src', src)
if (config.placeholder) {
img.setAttribute('src', config.placeholder)
} else {
img.removeAttribute('src')
}
}
})
return doc.body.innerHTML
}
let currentPage = 1
const itemsPerPage = 8
let totalPages = 0
@@ -117,7 +148,7 @@
</time>
</div>
</div>
<div class="shuoshuo-content">${item.content}</div>
<div class="shuoshuo-content">${addLazyload(item.content)}</div>
<div class="shuoshuo-footer ${tags ? 'flex-between' : 'flex-end'}">
${tags ? `<div class="shuoshuo-tags">${tags}</div>` : ''}
${commentButton}

View File

@@ -51,8 +51,8 @@ script.
const loadArtalk = async (el, pageKey) => {
if (typeof Artalk === 'object') initArtalk(el, pageKey)
else {
await btf.getCSS('!{theme.asset.artalk_css}')
await btf.getScript('!{theme.asset.artalk_js}')
await btf.getCSS('!{url_for(theme.asset.artalk_css)}')
await btf.getScript('!{url_for(theme.asset.artalk_js)}')
initArtalk(el, pageKey)
}
}

View File

@@ -6,7 +6,11 @@ script.
ele.forEach((item, index) => {
const mermaidSrc = item.firstElementChild
const mermaidThemeConfig = `%%{init:{ 'theme':'${theme}'}}%%\n`
const config = mermaidSrc.dataset.config ? JSON.parse(mermaidSrc.dataset.config) : {}
if (!config.theme) {
config.theme = theme
}
const mermaidThemeConfig = `%%{init: ${JSON.stringify(config)}}%%\n`
const mermaidID = `mermaid-${index}`
const mermaidDefinition = mermaidThemeConfig + mermaidSrc.textContent