rehype-autolink-headings adds className to all anchor tags even without headings #86
-
I'm working on a Next.JS blog (referring to the following article by LeeRob - link to source code) which uses MDX-Bundler to convert MDX blog posts to HTML. I'm using the The issue is that the xdmOptions(options) {
options.rehypePlugins = [
...(options.rehypePlugins ?? []),
rehypeSlug,
rehypeCodeTitles,
rehypePrism,
[
rehypeAutolinkHeadings,
{
properties: {
className: ['anchor']
}
}
]
];
return options;
}, Below is the screenshot of the HTML from my blog. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 5 replies
-
@AnweshGangula have your reached out to the author of the blog post?
I strongly suspect the issue is coming from another plugin or something the bundler is doing, but it's hard to say without seeing the exact code you are running and the exact versions of dependencies used with it. |
Beta Was this translation helpful? Give feedback.
-
This is 99.99% not a problem with the plugins rehype-slug or rehype-autolink-headings. |
Beta Was this translation helpful? Give feedback.
-
Thank you @wooorm @ChristianMurphy. Turns out that the issue was due to the component-substitution that I have in my I'm really new to Next.js, so I was not able to reduce the problem to a specific file until now. Really Appreciate you help. 🙌🙏 |
Beta Was this translation helpful? Give feedback.
Thank you @wooorm @ChristianMurphy.
Turns out that the issue was due to the component-substitution that I have in my
[slug.js]
file.This was over-writing all the
classnames
and replacing them with the substitute component all anchor tags.I'm really new to Next.js, so I was not able to reduce the problem to a specific file until now. Really Appreciate you help. 🙌🙏