From ace4fc82a9c193b74db502ad34f2aae88cfda7c3 Mon Sep 17 00:00:00 2001 From: developomp Date: Tue, 17 Aug 2021 11:11:58 +0900 Subject: [PATCH] added i and lvl to toc element --- source/src/pages/Page.tsx | 6 +++--- source/src/types/typings.d.ts | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/source/src/pages/Page.tsx b/source/src/pages/Page.tsx index 95b33be..ef61c14 100644 --- a/source/src/pages/Page.tsx +++ b/source/src/pages/Page.tsx @@ -104,11 +104,11 @@ const StyledMetaContainer = styled.div` })}; ` -function parseToc(json: TocElement[]) { +function parseToc(tocData: TocElement[]) { return (
    - {json.map((elem) => ( - // elem: content, i, lvl + {tocData.map((elem) => ( + // use elem.lvl
  1. {elem.content} diff --git a/source/src/types/typings.d.ts b/source/src/types/typings.d.ts index 1736c45..2b4debc 100644 --- a/source/src/types/typings.d.ts +++ b/source/src/types/typings.d.ts @@ -1,6 +1,8 @@ export interface TocElement { slug: string content: string + i: number + lvl: number } export interface Post {