Skip to content
This repository has been archived by the owner on Aug 31, 2023. It is now read-only.

Commit

Permalink
fix: anchor dont work on first click
Browse files Browse the repository at this point in the history
  • Loading branch information
BBSQQ authored and NewByVector committed Sep 10, 2020
1 parent 9ffa6c6 commit 8965228
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion @antv/gatsby-theme-antv/site/templates/document.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ const getDocument = (docs: any[], slug = '', level: number) => {
return docs.find((doc) => doc.slug === slug);
};

// https://github.com/antvis/gatsby-theme-antv/issues/114
const parseTableOfContents = (tableOfContents: string) => {
return tableOfContents.replace(/\/#/g, '#');
};

interface MenuData {
type: 'SubMenu' | 'Item';
title: string;
Expand Down Expand Up @@ -274,7 +279,7 @@ export default function Template({
className={styles.toc}
/* eslint-disable-next-line react/no-danger */
dangerouslySetInnerHTML={{
__html: tableOfContents,
__html: parseTableOfContents(tableOfContents),
}}
/>
</Affix>
Expand Down

0 comments on commit 8965228

Please sign in to comment.