Merge pull request #2175 from lxw15337674/feat/catalog

目录会填满侧边栏
This commit is contained in:
tangly1024
2024-03-17 15:05:15 +08:00
committed by GitHub
2 changed files with 20 additions and 24 deletions

View File

@@ -151,13 +151,12 @@ function AsideLeft(props) {
<DarkModeButton />
</section>
<section className='sticky top-0 pt-12'>
<section className='sticky top-0 pt-12 flex flex-col max-h-screen '>
<Catalog toc={post?.toc} />
<div className='flex justify-center'>
<div>{slot}</div>
</div>
</section>
</div>
</div>
}

View File

@@ -54,35 +54,32 @@ const Catalog = ({ toc }) => {
// 目录自动滚动
const tRef = useRef(null)
// 无目录就直接返回空
if (!toc || toc?.length < 1) {
return <></>
}
return <div id='catalog'>
return <div id='catalog' className='flex-1 flex-col flex overflow-hidden'>
<div className='w-full dark:text-gray-300 mb-2'><i className='mr-1 fas fa-stream' />{locale.COMMON.TABLE_OF_CONTENTS}</div>
<div className='h-96'>
<nav ref={tRef} className='h-full overflow-y-auto overscroll-none scroll-hidden text-black'>
{toc.map((tocItem) => {
const id = uuidToId(tocItem.id)
return (
<a
key={id}
href={`#${id}`}
className={`notion-table-of-contents-item duration-300 transform font-light dark:text-gray-300
<nav ref={tRef} className='flex-1 overflow-auto overscroll-none scroll-hidden text-black mb-6'>
{toc.map((tocItem) => {
const id = uuidToId(tocItem.id)
return (
<a
key={id}
href={`#${id}`}
className={`notion-table-of-contents-item duration-300 transform font-light dark:text-gray-300
notion-table-of-contents-item-indent-level-${tocItem.indentLevel} `}
>
<span style={{ display: 'inline-block', marginLeft: tocItem.indentLevel * 16 }}
className={`${activeSection === id && ' font-bold text-red-400 underline'}`}
title={tocItem.text}
>
<span style={{ display: 'inline-block', marginLeft: tocItem.indentLevel * 16 }}
className={`${activeSection === id && ' font-bold text-red-400 underline'}`}
>
{tocItem.text}
</span>
</a>
)
})}
</nav>
</div>
{tocItem.text}
</span>
</a>
)
})}
</nav>
</div>
}