Update table of contents

This commit is contained in:
Defectink
2022-04-01 15:15:38 +08:00
parent d68b4523ef
commit 11fcb9677f
7 changed files with 71 additions and 39 deletions

View 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&apos;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;