markdown-it-table-of-contents
Version:
A Markdown-it plugin for adding a table of contents to markdown documents
10 lines (9 loc) • 700 B
HTML
<h1 id="article">Article</h1>
<nav class="my-toc"><button>Toggle</button><h3>Table of Contents</h3><ul><li><ul><li><a href="#a-message-from-our-sponsors">A message from our sponsors</a></li></ul></li><li><a href="#hello">Hello world, I think you should read this article</a></li><li><a href="#what's-next%3F">What's next?</a><ul><li><ul><li><a href="#related">See related articles</a></li></ul></li></ul></li></ul></nav>
<h3 id="a-message-from-our-sponsors">A message from our sponsors</h3>
<p>Ad</p>
<h2 id="hello">Hello world, I think you should read this article</h2>
<p>Lorem ipsum</p>
<h2 id="what's-next%3F">What's next?</h2>
<p>Read this next...</p>
<h4 id="related">See related articles</h4>