mirror of
https://github.com/DefectingCat/DefectingCat.github.io
synced 2025-07-15 16:51:37 +00:00
Update table of contents
This commit is contained in:
29
components/post/PostTOC.tsx
Normal file
29
components/post/PostTOC.tsx
Normal file
@ -0,0 +1,29 @@
|
||||
import { FC } from 'react';
|
||||
import { getHeadings } from 'lib/utils';
|
||||
import Anchor from 'components/mdx/Anchor';
|
||||
|
||||
interface Props {
|
||||
headings: ReturnType<typeof getHeadings>;
|
||||
}
|
||||
|
||||
const PostTOC: FC<Props> = ({ headings }) => {
|
||||
return (
|
||||
<>
|
||||
<h2>What's inside?</h2>
|
||||
|
||||
<ul className="pl-4 border-l-4 border-gray-300">
|
||||
{headings?.map((h) => (
|
||||
<>
|
||||
<li>
|
||||
<Anchor href={h.link} external={false}>
|
||||
{h.text}
|
||||
</Anchor>
|
||||
</li>
|
||||
</>
|
||||
))}
|
||||
</ul>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default PostTOC;
|
Reference in New Issue
Block a user