import { useGlobal } from '@/lib/global' import { useGitBookGlobal } from '@/themes/gitbook' import { useRouter } from 'next/router' import { useEffect } from 'react' import Catalog from './Catalog' /** * 懸浮抽屜目錄 * @param toc * @param post * @returns {JSX.Element} * @constructor */ const CatalogDrawerWrapper = ({ post, cRef }) => { const { tocVisible, changeTocVisible } = useGitBookGlobal() const { locale } = useGlobal() const router = useRouter() const switchVisible = () => { changeTocVisible(!tocVisible) } useEffect(() => { changeTocVisible(false) }, [router]) return ( <>
{/* 側邊選單 */}
{post && ( <>
{locale.COMMON.TABLE_OF_CONTENTS} { changeTocVisible(false) }}>
)}
{/* 背景遮罩 */}
) } export default CatalogDrawerWrapper