Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/components/content/Button.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// `::button` is Nuxt UI's button.
export { default } from '@nuxt/ui/components/Button.vue'
2 changes: 2 additions & 0 deletions app/components/content/landing/Button.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// `::button` is Nuxt UI's button.
export { default } from '@nuxt/ui/components/Button.vue'
7 changes: 1 addition & 6 deletions app/pages/index.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
<script setup lang="ts">
import Button from '@nuxt/ui/components/Button.vue'

const landingComponents = {
...byFileName(import.meta.glob('../components/content/landing/*.{vue,ts}', { eager: true, import: 'default' })),
Button,
}
const landingComponents = byFileName(import.meta.glob('../components/content/landing/*.{vue,ts}', { eager: true, import: 'default' }))

const content = useDocsContent()
const site = useSiteConfig()
Expand All @@ -20,7 +15,7 @@
return p ? { ...p, nodes: prefixTreeLinks(p.nodes, content.value.routeBase) } : p
})

const fm = computed<Record<string, any>>(() => page.value?.data ?? {})

Check warning on line 18 in app/pages/index.vue

View workflow job for this annotation

GitHub Actions / ci

Unexpected any. Specify a different type

// Keep branch/commit previews out of search, same as DocsPage.
useRobotsRule(computed(() => (content.value.mode === 'prod' ? 'index, follow' : 'noindex, nofollow')))
Expand Down
3 changes: 1 addition & 2 deletions lint.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,10 @@ function componentsIn(/** @type {string} */ dir) {
const nuxtUi = dirname(fileURLToPath(import.meta.resolve('@nuxt/ui/components/Button.vue')))

// What the pages pass to `MarkdownDocument`: Nuxt UI's prose components and the layer's
// `app/components/content/`, plus every Nuxt UI component with the `u-` prefix, such as `::u-button`.
// `app/components/content/`, which re-exports the Nuxt UI components Markdown uses, such as `::button`.
const components = [
...componentsIn(`${nuxtUi}/prose`),
...componentsIn(fileURLToPath(new URL('app/components/content', import.meta.url))),
...readdirSync(nuxtUi).filter(file => file.endsWith('.vue')).map(file => `u-${kebab(basename(file, '.vue'))}`),
]

// Each page's URL, mapped to its file the way comark-content derives the URL from it.
Expand Down
10 changes: 0 additions & 10 deletions modules/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,16 +136,6 @@ export default defineNuxtModule<ComarkDocsOptions>({
},
})

// Extend Nuxt UI components to make them global and usable in markdown by consumers.
nuxt.hook('components:extend', (components) => {
const globalComponents = ['UButton', 'UPageHero']
for (const component of globalComponents) {
const entry = components.find((c) => c.pascalName === component)
if (!entry) continue
entry.global = true
}
})

const rawMcpOptions = nuxtOptions.mcp
const mcp = defu(rawMcpOptions || undefined, {
name: `${siteName} Docs`,
Expand Down
8 changes: 4 additions & 4 deletions playground/content/2.writing/3.components.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Beyond plain [Markdown](/writing/markdown), pages can use Vue components through
Three kinds of components are available in docs pages:

- **Nuxt UI prose components** — callouts, tabs, steps, and code widgets, available without any prefix.
- **Nuxt UI components** — any [Nuxt UI](https://ui.nuxt.com) component, with the `u-` prefix (`::u-button`).
- **Nuxt UI components** — the ones the layer re-exports, such as `::button` for [`UButton`](https://ui.nuxt.com/docs/components/button).
- **Layer components** — `Mermaid`, `CodeExplorer`, and `Browser`, injected by the docs page.

## Prose components
Expand Down Expand Up @@ -129,10 +129,10 @@ Other useful ones: `::tabs` with `:::tabs-item{label="..."}` children, `::collap

## Nuxt UI components

Any Nuxt UI component works with the `u-` prefix. The [landing page](/writing/landing-page) uses this for its hero:
`::button` renders Nuxt UI's [`UButton`](https://ui.nuxt.com/docs/components/button). The layer re-exports each Nuxt UI component Markdown can use from `app/components/content/`, so none is global. The [landing page](/writing/landing-page) uses it in its hero:

::code-preview
::u-button
::button
---
to: /getting-started/introduction
trailing-icon: i-lucide-arrow-right
Expand All @@ -141,7 +141,7 @@ Get started
::
#code
```mdc
::u-button
::button
---
to: /getting-started/introduction
trailing-icon: i-lucide-arrow-right
Expand Down
8 changes: 4 additions & 4 deletions playground/content/2.writing/4.landing-page.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,18 @@ The landing components below are only available in `content/index.md`. Docs page

## Hero

Use Nuxt UI's [`UPageHero`](https://ui.nuxt.com/docs/components/page-hero) with the `u-` prefix:
Use `::landing-hero`, which is Nuxt UI's [`UPageHero`](https://ui.nuxt.com/docs/components/page-hero), with `:::button` for its links:

```mdc
::u-page-hero
::landing-hero
#title
Docs that ship without a redeploy.

#description
Write Markdown, push, done.

#links
:::u-button
:::button
---
to: /getting-started/introduction
size: lg
Expand Down Expand Up @@ -209,7 +209,7 @@ Ready to ship docs faster?
Install the layer and push your first page.

#links
:::u-button{to="/getting-started/installation" size="lg"}
:::button{to="/getting-started/installation" size="lg"}
Get started
:::
::
Expand Down
2 changes: 1 addition & 1 deletion server/utils/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function runtimeCacheDriver(base: string, ttl?: number): Driver {
* Bump when content parser/plugin configuration, relevant parser dependencies, or cached derived
* data changes. Keeping this explicit lets unrelated deployments reuse immutable content artifacts.
*/
export const CONTENT_PARSER_VERSION = 'v5'
export const CONTENT_PARSER_VERSION = 'v6'

/**
* A ref pinned via `withRef()` is treated as immutable, so it can be cached for a long time.
Expand Down
Loading