diff --git a/themes/medium/components/BottomMenuBar.js b/themes/medium/components/BottomMenuBar.js index fee36eb2..23979d9e 100644 --- a/themes/medium/components/BottomMenuBar.js +++ b/themes/medium/components/BottomMenuBar.js @@ -4,7 +4,7 @@ import JumpToTopButton from './JumpToTopButton' export default function BottomMenuBar ({ post, className }) { const { tocVisible, changeTocVisible } = useMediumGlobal() - const showTocBotton = post?.toc?.length > 0 + const showTocButton = post?.toc?.length > 0 const toggleToc = () => { changeTocVisible(!tocVisible) @@ -18,13 +18,13 @@ export default function BottomMenuBar ({ post, className }) { -
+
- {showTocBotton &&
+ {showTocButton &&
} - { !showTocBotton && + { !showTocButton &&
diff --git a/themes/medium/index.js b/themes/medium/index.js index 1e3f365d..e35cdc28 100644 --- a/themes/medium/index.js +++ b/themes/medium/index.js @@ -51,12 +51,20 @@ const LayoutBase = props => { const router = useRouter() const [tocVisible, changeTocVisible] = useState(false) const { onLoading, fullWidth } = useGlobal() + const [slotRight, setSlotRight] = useState(null); + + useEffect(()=> { + if (post?.toc?.length > 0) { + setSlotRight( +
+ +
+ ); + } else { + setSlotRight(null); + } + },[post]) - const slotRight = post?.toc?.length > 0 && ( -
- -
- ) const slotTop = return ( @@ -178,7 +186,7 @@ const LayoutSlug = props => { }, [post]) return ( -
+
{/* 文章锁 */} {lock && }