Skip to content

Commit be426b0

Browse files
authored
Merge pull request tangly1024#2175 from lxw15337674/feat/catalog
目录会填满侧边栏
2 parents 17f9d9f + 74add36 commit be426b0

File tree

2 files changed

+20
-24
lines changed

2 files changed

+20
-24
lines changed

themes/fukasawa/components/AsideLeft.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -151,13 +151,12 @@ function AsideLeft(props) {
151151
<DarkModeButton />
152152
</section>
153153

154-
<section className='sticky top-0 pt-12'>
154+
<section className='sticky top-0 pt-12 flex flex-col max-h-screen '>
155155
<Catalog toc={post?.toc} />
156156
<div className='flex justify-center'>
157157
<div>{slot}</div>
158158
</div>
159159
</section>
160-
161160
</div>
162161
</div>
163162
}

themes/fukasawa/components/Catalog.js

+19-22
Original file line numberDiff line numberDiff line change
@@ -54,35 +54,32 @@ const Catalog = ({ toc }) => {
5454

5555
// 目录自动滚动
5656
const tRef = useRef(null)
57-
5857
// 无目录就直接返回空
5958
if (!toc || toc?.length < 1) {
6059
return <></>
6160
}
62-
63-
return <div id='catalog'>
61+
return <div id='catalog' className='flex-1 flex-col flex overflow-hidden'>
6462
<div className='w-full dark:text-gray-300 mb-2'><i className='mr-1 fas fa-stream' />{locale.COMMON.TABLE_OF_CONTENTS}</div>
65-
<div className='h-96'>
66-
<nav ref={tRef} className='h-full overflow-y-auto overscroll-none scroll-hidden text-black'>
67-
{toc.map((tocItem) => {
68-
const id = uuidToId(tocItem.id)
69-
return (
70-
<a
71-
key={id}
72-
href={`#${id}`}
73-
className={`notion-table-of-contents-item duration-300 transform font-light dark:text-gray-300
63+
<nav ref={tRef} className='flex-1 overflow-auto overscroll-none scroll-hidden text-black mb-6'>
64+
{toc.map((tocItem) => {
65+
const id = uuidToId(tocItem.id)
66+
return (
67+
<a
68+
key={id}
69+
href={`#${id}`}
70+
className={`notion-table-of-contents-item duration-300 transform font-light dark:text-gray-300
7471
notion-table-of-contents-item-indent-level-${tocItem.indentLevel} `}
72+
>
73+
<span style={{ display: 'inline-block', marginLeft: tocItem.indentLevel * 16 }}
74+
className={`${activeSection === id && ' font-bold text-red-400 underline'}`}
75+
title={tocItem.text}
7576
>
76-
<span style={{ display: 'inline-block', marginLeft: tocItem.indentLevel * 16 }}
77-
className={`${activeSection === id && ' font-bold text-red-400 underline'}`}
78-
>
79-
{tocItem.text}
80-
</span>
81-
</a>
82-
)
83-
})}
84-
</nav>
85-
</div>
77+
{tocItem.text}
78+
</span>
79+
</a>
80+
)
81+
})}
82+
</nav>
8683
</div>
8784
}
8885

0 commit comments

Comments
 (0)