added i and lvl to toc element

This commit is contained in:
Kim, Jimin 2021-08-17 11:11:58 +09:00
parent 74b523be23
commit ace4fc82a9
2 changed files with 5 additions and 3 deletions

View file

@ -104,11 +104,11 @@ const StyledMetaContainer = styled.div`
})};
`
function parseToc(json: TocElement[]) {
function parseToc(tocData: TocElement[]) {
return (
<ol>
{json.map((elem) => (
// elem: content, i, lvl
{tocData.map((elem) => (
// use elem.lvl
<li key={elem.slug}>
<HashLink smooth to={location.pathname + "#" + elem.slug}>
{elem.content}

View file

@ -1,6 +1,8 @@
export interface TocElement {
slug: string
content: string
i: number
lvl: number
}
export interface Post {