mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-09 15:17:23 +02:00
Use markdown-toc (#524)
This commit is contained in:
parent
632ccfb8cd
commit
c437f7be37
5 changed files with 186 additions and 26 deletions
|
@ -10,7 +10,14 @@ const React = require('react');
|
|||
const siteConfig = require(process.cwd() + '/siteConfig.js');
|
||||
const getTOC = require('../getTOC');
|
||||
|
||||
const Link = ({hashLink, text}) => <a href={`#${hashLink}`}>{text}</a>;
|
||||
const Link = ({hashLink, content}) => (
|
||||
<a
|
||||
href={`#${hashLink}`}
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: content,
|
||||
}}
|
||||
/>
|
||||
);
|
||||
|
||||
const Headings = ({headings}) => {
|
||||
if (!headings.length) return null;
|
||||
|
@ -18,7 +25,7 @@ const Headings = ({headings}) => {
|
|||
<ul className="toc-headings">
|
||||
{headings.map((heading, i) => (
|
||||
<li key={i}>
|
||||
<Link hashLink={heading.hashLink} text={heading.text} />
|
||||
<Link hashLink={heading.hashLink} content={heading.content} />
|
||||
<Headings headings={heading.children} />
|
||||
</li>
|
||||
))}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue