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 (
|
return (
|
||||||
<ol>
|
<ol>
|
||||||
{json.map((elem) => (
|
{tocData.map((elem) => (
|
||||||
// elem: content, i, lvl
|
// use elem.lvl
|
||||||
<li key={elem.slug}>
|
<li key={elem.slug}>
|
||||||
<HashLink smooth to={location.pathname + "#" + elem.slug}>
|
<HashLink smooth to={location.pathname + "#" + elem.slug}>
|
||||||
{elem.content}
|
{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 {
|
export interface TocElement {
|
||||||
slug: string
|
slug: string
|
||||||
content: string
|
content: string
|
||||||
|
i: number
|
||||||
|
lvl: number
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Post {
|
export interface Post {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue