added i and lvl to toc element
This commit is contained in:
parent
74b523be23
commit
ace4fc82a9
2 changed files with 5 additions and 3 deletions
|
@ -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}
|
||||
|
|
2
source/src/types/typings.d.ts
vendored
2
source/src/types/typings.d.ts
vendored
|
@ -1,6 +1,8 @@
|
|||
export interface TocElement {
|
||||
slug: string
|
||||
content: string
|
||||
i: number
|
||||
lvl: number
|
||||
}
|
||||
|
||||
export interface Post {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue