code-hike / codehike

Build rich content websites with Markdown and React
https://codehike.org
MIT License
4.74k stars 147 forks source link

Parse Code Hike headings anchors in Docusarus TOC #226

Closed evanorti closed 2 years ago

evanorti commented 2 years ago

Scrollycode allows you to write explanations with markdown headings. Docusaurus turns headings within Scrollycode into heading anchors, but they don't appear in the auto-generated TOC on the right of each page. Markdown headings outside of Code Hike sections still render in TOC as normal.

Generating Code Hike headings to the TOC is important for easy navigation.

Screen Shot 2022-07-15 at 9 27 29 AM

There is a similar issue with Nextra. If you use Code Hike with Nextra, the auto-generated headings feature is broken, and no headings are parsed as anchors, even outside of Code Hike sections.

pomber commented 2 years ago

Not sure about Nextra, but the Docusaurus issue comes from docusaurus-theme-mdx-v2.

You can try wrapping the headings inside a <div/> and it also won't work:

<div>

## h2

### h3

</div>

Here's the issue https://github.com/pomber/docusaurus-mdx-2/issues/3

pomber commented 2 years ago

Upgrading docusaurus-theme-mdx-v2 to v0.1.2 should fix it (for docusaurus)

evanorti commented 2 years ago

Awesome! thanks!