Use markdown-toc (#524)

This commit is contained in:
Elian Ibaj 2018-04-04 19:19:03 +02:00 committed by Joel Marcey
parent 632ccfb8cd
commit c437f7be37
5 changed files with 186 additions and 26 deletions

View file

@ -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>
))}