diff --git a/components/PrismMac.js b/components/PrismMac.js
index 731060b6..830687fe 100644
--- a/components/PrismMac.js
+++ b/components/PrismMac.js
@@ -70,7 +70,9 @@ const renderMermaid = async() => {
}
}
})
- observer.observe(document.querySelector('#notion-article'), { attributes: true, subtree: true })
+ if (document.querySelector('#notion-article')) {
+ observer.observe(document.querySelector('#notion-article'), { attributes: true, subtree: true })
+ }
}
function renderPrismMac() {
diff --git a/themes/gitbook/LayoutBase.js b/themes/gitbook/LayoutBase.js
index 99384af9..f2f28bf8 100644
--- a/themes/gitbook/LayoutBase.js
+++ b/themes/gitbook/LayoutBase.js
@@ -16,6 +16,7 @@ import Catalog from './components/Catalog'
import { useRouter } from 'next/router'
import Announcement from './components/Announcement'
import PageNavDrawer from './components/PageNavDrawer'
+import FloatTocButton from './components/FloatTocButton'
const ThemeGlobalMedium = createContext()
/**
@@ -32,6 +33,8 @@ const LayoutBase = (props) => {
const { onLoading } = useGlobal()
const router = useRouter()
+ const showTocButton = post?.toc?.length > 1
+
useEffect(() => {
setFilterPosts(allNavPages)
}, [post])
@@ -109,6 +112,10 @@ const LayoutBase = (props) => {
+ {showTocButton && !tocVisible &&
+
+
}
+
{/* 移动端底部导航栏 */}
diff --git a/themes/gitbook/components/BottomMenuBar.js b/themes/gitbook/components/BottomMenuBar.js
index c3348bc3..2c7cdffc 100644
--- a/themes/gitbook/components/BottomMenuBar.js
+++ b/themes/gitbook/components/BottomMenuBar.js
@@ -1,15 +1,9 @@
-import Link from 'next/link'
import React from 'react'
import { useMediumGlobal } from '../LayoutBase'
import JumpToTopButton from './JumpToTopButton'
export default function BottomMenuBar({ post, className }) {
- const { tocVisible, changeTocVisible, pageNavVisible, changePageNavVisible } = useMediumGlobal()
- const showTocBotton = post?.toc?.length > 0
-
- const toggleToc = () => {
- changeTocVisible(!tocVisible)
- }
+ const { pageNavVisible, changePageNavVisible } = useMediumGlobal()
const togglePageNavVisible = () => {
changePageNavVisible(!pageNavVisible)
@@ -19,19 +13,11 @@ export default function BottomMenuBar({ post, className }) {
-
+
- {showTocBotton &&
-
-
}
- {!showTocBotton &&
-
-
-
- }
)
diff --git a/themes/gitbook/components/FloatTocButton.js b/themes/gitbook/components/FloatTocButton.js
new file mode 100644
index 00000000..cfbb265e
--- /dev/null
+++ b/themes/gitbook/components/FloatTocButton.js
@@ -0,0 +1,22 @@
+import { useMediumGlobal } from '../LayoutBase'
+
+export default function FloatTocButton () {
+ const { tocVisible, changeTocVisible } = useMediumGlobal()
+
+ const toggleToc = () => {
+ changeTocVisible(!tocVisible)
+ }
+
+ return (
+
+ )
+}
diff --git a/themes/gitbook/components/MenuItemCollapse.js b/themes/gitbook/components/MenuItemCollapse.js
index 539419eb..5cdb6973 100644
--- a/themes/gitbook/components/MenuItemCollapse.js
+++ b/themes/gitbook/components/MenuItemCollapse.js
@@ -32,7 +32,7 @@ export const MenuItemCollapse = (props) => {
}
return <>
-
+
{!hasSubMenu &&
diff --git a/themes/gitbook/components/PageNavDrawer.js b/themes/gitbook/components/PageNavDrawer.js
index 062629cc..3bfc39b9 100644
--- a/themes/gitbook/components/PageNavDrawer.js
+++ b/themes/gitbook/components/PageNavDrawer.js
@@ -18,7 +18,7 @@ const PageNavDrawer = ({ post, cRef }) => {