What is remark-slug?
The remark-slug npm package is a plugin for the remark Markdown processor that automatically adds slugs to headings in a Markdown document. This is useful for generating links to specific sections of the document, enhancing navigation and accessibility.
Automatic Slug Generation
This feature automatically generates slugs for each heading in a Markdown document. The code sample shows how to use remark-slug with remark and remark-html to convert a Markdown heading into HTML with a slug.
const remark = require('remark');
const remarkHtml = require('remark-html');
const remarkSlug = require('remark-slug');
remark()
.use(remarkSlug)
.use(remarkHtml)
.process('# Hello world', function (err, file) {
console.log(String(file));
});