mirror of
https://github.com/jerryc127/hexo-theme-butterfly.git
synced 2026-04-12 22:17:06 +08:00
feat: 修改 toc 打開效果
feat: 適配 hexo-blog-encrypt fix: 修復 hexo 新版本下,prismjs 的問題 improvement: 在 pjax 關閉的情況下。減少不必要的全局變量 improvement: 更新依賴版本 improvement: 頁面進入效果優化 improvement: 添加平滑滾動 improvement: 兼容性優化 improvement: 優化 lighthouse 分數 improvement: 優化代碼
This commit is contained in:
18
layout/includes/third-party/math/mermaid.pug
vendored
18
layout/includes/third-party/math/mermaid.pug
vendored
@@ -1,12 +1,10 @@
|
||||
script.
|
||||
(() => {
|
||||
const $mermaid = document.querySelectorAll('#article-container .mermaid-wrap')
|
||||
if ($mermaid.length === 0) return
|
||||
const runMermaid = () => {
|
||||
const runMermaid = (ele) => {
|
||||
window.loadMermaid = true
|
||||
const theme = document.documentElement.getAttribute('data-theme') === 'dark' ? '!{theme.mermaid.theme.dark}' : '!{theme.mermaid.theme.light}'
|
||||
|
||||
Array.from($mermaid).forEach((item, index) => {
|
||||
Array.from(ele).forEach((item, index) => {
|
||||
const mermaidSrc = item.firstElementChild
|
||||
const mermaidThemeConfig = '%%{init:{ \'theme\':\'' + theme + '\'}}%%\n'
|
||||
const mermaidID = 'mermaid-' + index
|
||||
@@ -29,10 +27,14 @@ script.
|
||||
}
|
||||
|
||||
const loadMermaid = () => {
|
||||
window.loadMermaid ? runMermaid() : getScript('!{url_for(theme.asset.mermaid)}').then(runMermaid)
|
||||
const $mermaid = document.querySelectorAll('#article-container .mermaid-wrap')
|
||||
if ($mermaid.length === 0) return
|
||||
|
||||
const runMermaidFn = () => runMermaid($mermaid)
|
||||
btf.addGlobalFn('themeChange', runMermaidFn, 'mermaid')
|
||||
window.loadMermaid ? runMermaidFn() : btf.getScript('!{url_for(theme.asset.mermaid)}').then(runMermaidFn)
|
||||
}
|
||||
|
||||
btf.addGlobalFn('themeChange', runMermaid, 'mermaid')
|
||||
|
||||
|
||||
btf.addGlobalFn('encrypt', loadMermaid, 'mermaid')
|
||||
window.pjax ? loadMermaid() : document.addEventListener('DOMContentLoaded', loadMermaid)
|
||||
})()
|
||||
Reference in New Issue
Block a user