Replies: 2 comments 7 replies
-
Welcome @artola! 👋 Rehype plugins in the middle of the pipeline. It may be possible to create a slugger that uses file information to ensure the slugs are unique |
Beta Was this translation helpful? Give feedback.
-
What is your root case? The line of thinking I’d recommend going into, is the same as what GH is doing for footnotes in comments: they prefix IDs in each comment, with an ID unique to that comment. That way, a page can have multiple documents, and IDs are “scoped” to the subdocument. |
Beta Was this translation helpful? Give feedback.
-
I have
foo.mdx
that importsbar.mdx
, my output is kinda ok, but the plugins are working in isolation for each file, and they do not share any context (or I could not find a way to do it).For example, just using
rehype-slug
. The idea is to add an id to the headings and it does it, just that also repeating the same "id" in place of adding a trailing number to differentiate them.The output contains 2 headers with exactly the same
id
(xxx
), in place ofxxx-1
andxxx-2
as if both were in the same file.As far as I did debug, the compilation treats the files as different
tree
not connected.In my case, I wrote a plugin to collect the headings, all of them, and I can see the plugin running on each file and I do not see a way to group them (using NextJS, with the default config and
rehype-slug
).Can someone give me a hint how to solve such situation? is there a way to share context in the loader that gets reset on every run?
Beta Was this translation helpful? Give feedback.
All reactions