Robot-Inventor / astro-custom-toc

Astro Integration to generate a customizable table of contents
MIT License
5 stars 0 forks source link

fix: improve compatibility with other plugins #20

Closed Robot-Inventor closed 6 months ago

Robot-Inventor commented 8 months ago

If the heading already has an id set by another plugin, use it; otherwise, set the id.

Robot-Inventor commented 7 months ago

ref: https://github.com/syntax-tree/mdast-util-toc/blob/c96a9eb446a8426b53cf2b68cf6655f3f2600420/lib/search.js#L96

Robot-Inventor commented 7 months ago

Since Astro sets the id of the headings in rehype, it is not possible to get the id from the remark plugin.

ref: https://github.com/withastro/astro/blob/297571eb98509a63f894d6fff912775b637a1482/packages/markdown/remark/src/rehype-collect-headings.ts