fix gitbook & mermaid

This commit is contained in:
tangly1024
2023-06-24 21:08:26 +08:00
parent ffc3fb984b
commit e0b9f33bbe
2 changed files with 5 additions and 4 deletions

View File

@@ -12,12 +12,14 @@ import 'prismjs/plugins/line-numbers/prism-line-numbers.css'
// mermaid图
import BLOG from '@/blog.config'
import { isBrowser, loadExternalResource } from '@/lib/utils'
import { useRouter } from 'next/router'
/**
* @author https://github.com/txs/
* @returns
*/
const PrismMac = () => {
const router = useRouter()
useEffect(() => {
if (isBrowser()) {
if (BLOG.CODE_MAC_BAR) {
@@ -33,7 +35,7 @@ const PrismMac = () => {
renderMermaid()
})
}
}, [])
}, [router.events])
return <></>
}
@@ -70,8 +72,8 @@ const renderMermaid = async() => {
}
}
})
if (document.querySelector('#notion-article')) {
observer.observe(document.querySelector('#notion-article'), { attributes: true, subtree: true })
if (document.querySelector('#container-inner')) {
observer.observe(document.querySelector('#container-inner'), { attributes: true, subtree: true })
}
}

View File

@@ -50,7 +50,6 @@ const Catalog = ({ post }) => {
setActiveSection(currentSectionId)
const index = tocIds.indexOf(currentSectionId) || 0
if (isBrowser() && tocIds?.length > 0) {
console.log(28 * index, index, currentSectionId)
for (const tocWrapper of document?.getElementsByClassName('toc-wrapper')) {
tocWrapper?.scrollTo({ top: 28 * index, behavior: 'smooth' })
}