-
-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pass VFile Data Back #96
Comments
Hey!
And the file contains mangled JavaScript — you probably don’t want that. You want an array or so? What I think is a good solution, would be to somehow add a new export to the file. export const tableOfContents = { … }
export default function MDXContent() { … } Things like these are possible through plugins, in userland. Here is one similar example: https://github.com/remcohaszing/rehype-mdx-title/blob/main/src/index.ts. It adds an export for the I think it would be quite useful for other people to have such a plugin! |
Let me see if I can make it to work ... honestly, I have no clue what I am doing. Should I make it to work over JS-DevTools/rehype-toc#8 since that is what most people seem to be using? |
Doing what I can, stefanprobst/rehype-extract-toc#2 But I am just copy-pasting code, and try-and-error until works, any mentoring is welcome ❤️ |
I am very lost now, I am using |
Also, how can we extract the information without having to inject it back to some output? The intention is not to expose it but collect it thou (but I digress I take anything at this point) |
(Sorry I am spamming here, learning in the public) I think I am using the wrong tooling and/or there is some ecosystem context that I am missing. From one side, definitely handle exporting things as part of the file, on the other hand, I want to extract the ToC. And lastly, Why would I keep adding plugins to So, do I suppose to include only plugins that will help
Not working, for example |
I'd highly recommend reading https://unifiedjs.com/learn/ if you haven't already, it introduces the ecosystem and some of the common patterns. More broadly your question increasingly sounds like an XY problem. Reading between the lines of your comments, you want the TOC external to the component being generated? Something like a sitemap? If so could you expand on how you want to use this information external to the component?
MDX can share values through exports, https://github.com/remcohaszing/rehype-mdx-title#usage import MDXContentCompoent, { title } from './example.mdx' |
@ChristianMurphy definitely reading as much as I can right now, honestly speaking, I read many things before thou, but way too many things to figure out. import MDXContentCompoent, { title } from './example.mdx' That totally makes sense, I think I am so sorry folks, I am trying to learn.
Right, I need the TOC externally from the So I need to extract the frontmatter, and the TOC. If you don't mind helping me thou, should I drop btw, I do see the Sorry folks, really appreciate your patience and support. |
Would importing the data, and feeding it to your table of contents component, similar to: import MDXContentCompoent, { title, tableOfContents } from './example.mdx'
<TableOfContentsComponent tableOfContents={tableOfContents} /> work?
Again, understanding the why is important, this is another XY question.
What did you switch from? Why did you switch? Is there a feature from
Right, It's a JavaScript file as a string, it needs to be evaluated for it to run. |
Yeah ... let me go back to Honestly, I think I talked myself from Let me reset, and focus on the goal, hopefully, I can make it work now since I start to understand a bit better, definitely that |
Things like, https://github.com/kentcdodds/mdx-bundler#:~:text=mdx%2Dbundler%20is%20an%20MDX,built%20version%20of%20your%20files.
Which @wooorm you are part the mdx crew, so maybe you have some feedback on the topic? maybe that is not true anymore with |
@yordis I understand you mean well, but there’s a couple of things going wrong here:
|
@wooorm sorry, something got lost, as I mentioned before, trying to learn in public to let a trace of my failures rather than keeping them for myself for the next person that needs things. I am not demanding anything from anyone as far as I can tell, unless I made a mistake, my apologies if so, but you are entitled to your time, and whatever you decide to do with it it is up to you. You are free to ignore the thread and unsubscribe, otherwise, if you wish me to stop sharing thins here I will since it is your space. For what is worth, thank you so much for your patience and support. I will figure it out. |
I think the quite vocal learning in public here in issues caught me off guard. I have no problem with you learning in public, but I don’t think an issue here on GitHub is the right place. Perhaps a blog post / digital garden might be the right place? I see issues as a place to talk about actionable things: if there’s no need to change something in the respective project, the conversation is over/moves somewhere else. This has in part to do with how GitHub and related things is set up: I get notifications any time, anyone comments, on any of the hundreds of projects I maintain, and notifications/issues are something to be solved/closed, otherwise projects are treated as unmaintained. |
All good, no need for explanation, it is totally reasonable and understandable where you are coming from, I made a mistake. Will not happen again. Cheers, |
Hey @yordis, I've got a similar use-case and trying to follow your tracks. |
Initial checklist
Subject
Pass the VFile data back to
mdx-bundler
Problem
I am using
mdx-bundler
, with the following rehype plugin@stefanprobst/rehype-extract-toc
here: https://github.com/straw-hat-team/adr/blob/9171dd779c13ff86caf951ac33c01d4cf9fc3d57/website/src/pages/adrs/%5Bslug%5D.tsx#L30@stefanprobst/rehype-extract-toc
does the following https://github.com/stefanprobst/rehype-extract-toc/blob/6136d102bba79a2457a3749e193e913a4e3b6ee2/src/index.js#L13Such code adds
toc
to the VFile data.I traced the code, and until here:
xdm/lib/integration/esbuild.js
Line 135 in 051b49f
vfile.data.toc
is there.But then we don't do anything with, here:
xdm/lib/integration/esbuild.js
Line 202 in 051b49f
So the data is lost, therefore I didn't get the
vfile.data
in my compiled output inmdx-bundler
here https://github.com/straw-hat-team/adr/blob/9171dd779c13ff86caf951ac33c01d4cf9fc3d57/website/src/helpers/mdx.ts#L99Solution
Pass somehow
vfile.data
back, I think we need to update thecontents
to be a JSON with two keys at least, so we can pass that information as well.Alternatives
🤷🏻 don't understand much, I am not sure
The text was updated successfully, but these errors were encountered: