Skip to content

Commit 73ecf0a

Browse files
committed
docs: raw content
1 parent e0f7bf5 commit 73ecf0a

File tree

4 files changed

+58
-3
lines changed

4 files changed

+58
-3
lines changed

docs/content/2.usage/2.markdown.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -549,13 +549,13 @@ const mdcVars = ref({ name: 'Maxime'});
549549

550550
### Prose Components
551551

552-
In Nuxt Content, the prose represents HTML tags generated by the Markdown syntax, such as title levels and links.
552+
In Nuxt Content, the prose represents HTML tags generated by the Markdown syntax, such as heading levels and links.
553553

554554
For each HTML tag, a Vue component is used, allowing you to override them if needed, for example `<p>` becomes `<ProseP>`.
555555

556556
If you want to customize a Prose component, here are the recommended steps:
557557

558-
- Checkout the original [component sources](https://github.com/nuxt-modules/mdc/blob/main/src/runtime/components/prose).
558+
- Check out the original [component sources](https://github.com/nuxt-modules/mdc/blob/main/src/runtime/components/prose).
559559
- Use the exact same props.
560560
- In your `components/content/` directory, give it the same name.
561561
- Make it yours 🚀.

docs/content/6.snippets/1.fulltext-search.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ You can use the result of this utility in combination with [Nuxt UI Content Sear
99

1010
## Nuxt UI Pro
1111

12-
Nuxt UI Pro provide a ready to use component for full-text search. You can use it by passing the result of `queryCollectionSearchSections` to the `files` prop of the component.
12+
Nuxt UI Pro provides a ready to use component for full-text search. You can use it by passing the result of `queryCollectionSearchSections` to the `files` prop of the component.
1313

1414
Read more about [Nuxt UI Content Search][nuxt-ui-content-search].
1515

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
---
2+
title: Raw Content
3+
description: Access to contents raw data in appliction
4+
---
5+
6+
There were lots of requests in Content version 2 about accessing contents raw data in production. We're happy to announce that in version 3 it is possible to ship contents raw data to production.
7+
8+
In order to ship raw contents to production you need to define `rawbody` field in your collection's schema.
9+
That's it.
10+
11+
Nuxt Content will detect this magical field in your schema and fill it with the raw content.
12+
13+
```ts [content.config.ts]
14+
import { defineCollection, z } from '@nuxt/content'
15+
16+
export const collections = {
17+
docs: defineCollection({
18+
source: '**',
19+
type: 'page',
20+
schema: z.object({
21+
rawbody: z.string()
22+
})
23+
})
24+
}
25+
```
26+
27+
And you can use `queryCollection()`{lang="ts-type"} to fetch the raw content.
28+
29+
```vue [pages/index.vue]
30+
<script setup lang="ts">
31+
const route = useRoute()
32+
const { data } = useAsyncData('page-' + route.path, () => queryCollection('docs').path(route.path).first())
33+
</script>
34+
35+
<template>
36+
<pre>{{ data.rawbody }}</pre>
37+
</template>
38+
```
39+
40+
41+
In case you don't want to ship raw content of a specific file you can add `rawbody: ''` to frontmatter of that file. The auto filled value of `rawbody` is acting like default value and when you define `rawbody` in the frontmater it will overwriten.
42+
43+
```md [content.md]
44+
---
45+
title: My page
46+
rawbody: ''
47+
---
48+
49+
```
50+
51+
52+
::callout
53+
It is important to fill frontmatter fields with a same type of data that defined in collection schema. In this case `rawbody` is a string, and you should consider passing empry string. Do not use `boolean` or other type of values.
54+
::

playground/content.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const content = defineCollection({
1111
},
1212
schema: z.object({
1313
date: z.date(),
14+
rawbody: z.string(),
1415
}),
1516
})
1617

0 commit comments

Comments
 (0)