Skip to content

Conversation

@ace-of-aces
Copy link
Contributor

πŸ”— Linked issue

-

❓ Type of change

  • πŸ“– Documentation (updates to the documentation, readme or JSdoc annotations)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to 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 .md ending 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:

::component-preview
---
name: ButtonDemo
description: A button
---
::

would provide way better information when resolved to a code block with the actual code of the demo:

```vue
<script setup lang="ts">
import { ArrowUpIcon } from 'lucide-vue-next'
import { Button } from '@/registry/new-york-v4/ui/button'
</script>

<template>
  <div class="flex flex-wrap items-center gap-2 md:flex-row">
    <Button variant="outline">
      Button
    </Button>
    <Button variant="outline" size="icon" aria-label="Submit">
      <ArrowUpIcon />
    </Button>
  </div>
</template>

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 transformMDC function 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

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@sadeghbarati sadeghbarati merged commit 67307bb into unovue:v4-docs Nov 2, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants