docs(v4): add missing raw markdown route #1512
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
π Linked issue
-
β Type of change
π Description
This adds a missing server route for the "View as Markdown" feature on docs pages that zernonia recently added to the v4 docs.
Details
Essentially, this does the same as "Copy Page", as it just serves the raw markdown source content (
page.rawbody).The route is prefixed with
/raw, as I've not found another way to distinguish actual documentation pages from raw markdown pages just by the.mdending with Nuxt's file based routing.Things to consider
With this implementation we're only serving the raw markdown source files, and not resolving MDC components which are inside of these files. As this feature is especially intended for giving context to LLMs, there is possibly important context missing that would be valuable to an LLM.
Example:
would provide way better information when resolved to a code block with the actual code of the demo:
shadcn/ui doesn't have this issue: They're using fumadocs that does this under the hood, which therefore can't be applied to this project.
I've looked into how other Nuxt projects are approaching this, and I've looked into how Nuxt UI does it. They're using the server route approach that I've adapted in this PR, and they've written a huge custom
transformMDCfunction that's also entangled with their project structure, but does the important part of resolving components.Sources: https://github.com/nuxt/ui/blob/v4/docs/server/utils/transformMDC.ts, https://github.com/nuxt/ui/blob/v4/docs/server/routes/raw/%5B...slug%5D.md.get.ts
So, what do you guys think about this? Should we add something like this to this project, are there better approaches, or are there just more important things right now?π
Also, should I open another issue/discussion for this, or just address it in this PR?
πΈ Screenshots (if appropriate)
-
π Checklist