Merge pull request #602 from tangly1024/release/3.6.6

Release/3.6.6
This commit is contained in:
tangly1024
2022-12-15 13:56:31 +08:00
committed by GitHub
3 changed files with 28 additions and 26 deletions

View File

@@ -8,7 +8,6 @@ import 'prismjs/plugins/line-numbers/prism-line-numbers.css'
// 所有语言的prismjs 使用autoloader引入
import 'prismjs/plugins/autoloader/prism-autoloader'
// mermaid图
import mermaid from 'mermaid'
import BLOG from '@/blog.config'
/**
@@ -18,6 +17,7 @@ import BLOG from '@/blog.config'
const PrismMac = () => {
React.useEffect(() => {
renderPrismMac()
renderMermaid()
// 折叠代码行号bug
const observer = new MutationObserver(mutationsList => {
@@ -35,21 +35,10 @@ const PrismMac = () => {
return <></>
}
function renderPrismMac() {
const container = document?.getElementById('container-inner')
const codeToolBars = container?.getElementsByClassName('code-toolbar')
// Add line numbers
const codeBlocks = container?.getElementsByTagName('pre')
if (codeBlocks) {
Array.from(codeBlocks).forEach(item => {
if (!item.classList.contains('line-numbers')) {
item.classList.add('line-numbers')
item.style.whiteSpace = 'pre-wrap'
}
})
}
/**
* 将mermaid语言 渲染成图片
*/
const renderMermaid = async() => {
// 支持 Mermaid
const mermaidPres = document.querySelectorAll('pre.notion-code.language-mermaid')
if (mermaidPres) {
@@ -73,9 +62,26 @@ function renderPrismMac() {
}
}
if (needLoad) {
mermaid.contentLoaded()
const asyncMermaid = await import('mermaid')
asyncMermaid.default.contentLoaded()
}
}
}
function renderPrismMac() {
const container = document?.getElementById('container-inner')
const codeToolBars = container?.getElementsByClassName('code-toolbar')
// Add line numbers
const codeBlocks = container?.getElementsByTagName('pre')
if (codeBlocks) {
Array.from(codeBlocks).forEach(item => {
if (!item.classList.contains('line-numbers')) {
item.classList.add('line-numbers')
item.style.whiteSpace = 'pre-wrap'
}
})
}
// 重新渲染之前检查所有的多余text

View File

@@ -94,11 +94,6 @@ bszTag = {
}
}
// 修复Node同构代码的问题
if (typeof document !== 'undefined') {
fetch()
}
module.exports = {
fetch
}

View File

@@ -11,10 +11,6 @@ import Progress from './Progress'
* @constructor
*/
const Toc = ({ toc }) => {
// 无目录就直接返回空
if (!toc || toc.length < 1) {
return <></>
}
// 监听滚动事件
React.useEffect(() => {
window.addEventListener('scroll', actionSectionScrollSpy)
@@ -58,6 +54,11 @@ const Toc = ({ toc }) => {
tRef?.current?.scrollTo({ top: 28 * index, behavior: 'smooth' })
}, throttleMs))
// 无目录就直接返回空
if (!toc || toc.length < 1) {
return <></>
}
return <div className='px-3'>
<div className='w-full pb-1'>
<Progress />