diff --git a/components/PrismMac.js b/components/PrismMac.js index 830687fe..060d6b94 100644 --- a/components/PrismMac.js +++ b/components/PrismMac.js @@ -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 }) } } diff --git a/themes/gitbook/components/Catalog.js b/themes/gitbook/components/Catalog.js index df7484a6..5a51bee6 100644 --- a/themes/gitbook/components/Catalog.js +++ b/themes/gitbook/components/Catalog.js @@ -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' }) }