@altano/remark-mdx-toc-with-slugs
v3.0.0
Published
A remark plugin to generate a table of contents (including slugs) and convert it into MDX export
Downloads
231
Maintainers
Readme
remark-mdx-toc-with-slugs
Summary
This is a remark plugin that exports a table of contents. It is similar to the @altano/remark-mdx-toc plugin but has an additional slug
property.
Given this mdx:
## Resource Acquisition Is Initialization (RAII)
### Is There a Problem?
### C++ Classes
### The Solution
remark-mdx-toc-with-slugs
exports this object on the toc
field:
export const toc = [
{
depth: 2,
value: "Resource Acquisition Is Initialization (RAII)",
slug: "resource-acquisition-is-initialization-raii",
attributes: {},
children: [
{
depth: 3,
value: "Is There a Problem?",
attributes: {},
children: [],
slug: "is-there-a-problem",
},
{
depth: 3,
value: "C++ Classes",
attributes: {},
children: [],
slug: "c-classes",
},
{
depth: 3,
value: "The Solution",
attributes: {},
children: [],
slug: "the-solution",
},
],
},
];
Options
name
: The exported variable name of the table of contents. By default, it'stoc
.
Misc
- If you don't need the slug, consider using @altano/remark-mdx-toc.
- Slugs are generated using
github-slugger
and should therefore match therehype-slug
package