Skip to content

Commit 1dac4d5

Browse files
committed
docs: update
1 parent 0d2c690 commit 1dac4d5

File tree

11 files changed

+86
-165
lines changed

11 files changed

+86
-165
lines changed

docs/content/docs/1.getting-started/3.collections.md

Lines changed: 65 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,15 @@ export const collections = {
3434
}
3535
```
3636

37+
::note{to="#collection-types"}
38+
Learn more about the different types of collections.
39+
::
40+
3741
### Collection Schema
3842

3943
Schemas enforce data consistency within a collection and serve as the source of truth for TypeScript types.
4044

41-
Define a schema by adding the `schema` property to your collection by using a [`zod`](https://zod.dev) schema:
45+
On top of the [built-in fields](#built-in-fields), you can define a schema by adding the `schema` property to your collection by using a [`zod`](https://zod.dev) schema:
4246

4347
```ts [content.config.ts]
4448
import { defineCollection, z } from '@nuxt/content'
@@ -48,7 +52,7 @@ export const collections = {
4852
source: '**.md',
4953
type: 'page',
5054
// Define custom schema for docs collection
51-
schema: z.object({ // Schema must be an object
55+
schema: z.object({
5256
tags: z.array(z.string()),
5357
image: z.string(),
5458
date: z.Date()
@@ -84,7 +88,7 @@ export const collections = {
8488

8589
## Querying Collections
8690

87-
Use the [`queryCollection`](/docs/composables/query-collection) util to fetch one or all items from a collection:
91+
Use the [`queryCollection`](/docs/utils/query-collection) util to fetch one or all items from a collection:
8892

8993
```vue [pages/blog.vue]
9094
<script setup lang="ts">
@@ -106,3 +110,61 @@ const { data: posts } = await useAsyncData('blog', () => queryCollection('blog')
106110
::note{to="/api/query-collection"}
107111
Learn more about the available query options in our `queryCollections` API documentation.
108112
::
113+
114+
## defineCollection()
115+
116+
The `defineCollection` function defines a collection in your content configuration. Here's its TypeScript signature:
117+
118+
```ts
119+
function defineCollection(collection: Collection): DefinedCollection
120+
121+
type Collection = {
122+
// Determines how content is processed
123+
type: 'page' | 'data'
124+
// Specifies content location
125+
source?: string | CollectionSource
126+
// Zod schema for content validation and typing
127+
schema?: ZodObject<T>
128+
}
129+
130+
type CollectionSource = {
131+
// Glob pattern for content matching
132+
include: string
133+
// .path prefix (only applies to 'page' type)
134+
prefix?: string
135+
// Glob patterns to exclude content
136+
exclude?: string[]
137+
// Root directory for content matching
138+
cwd?: string
139+
// Remote git repository URL (e.g., https://github.com/nuxt/content)
140+
repository?: string
141+
}
142+
```
143+
144+
### Collection Types
145+
146+
The `type` parameter determines content processing:
147+
- `data`: For structured data files (JSON, YAML) that don't require rendering
148+
- `page`: For full pages with layouts and components that need rendering
149+
150+
### Built-in Fields
151+
152+
Every collection includes these default fields:
153+
154+
- `_id`: Unique content identifier
155+
- `stem`: File path without extension (used for sorting and location)
156+
- `extension`: File extension
157+
- `meta`: Custom fields not defined in the collection schema
158+
159+
Additional fields for `page` type collections:
160+
161+
- `path`: Generated route path
162+
- `title`: Page title
163+
- `description`: Page description
164+
- `seo`: SEO metadata (to be used with Nuxt's `useSeoMeta` composable)
165+
- `body`: Page content parsed as AST
166+
- `navigation`: Page navigation configuration (for [`queryCollectionNavigation](/docs/composables/query-collection-navigation))
167+
168+
### Returns
169+
170+
The function returns the defined collection object.

docs/content/docs/3.composables/10.defineCollection.md

Lines changed: 0 additions & 116 deletions
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
icon: i-lucide-square-function
2+
title: Vue Utils
File renamed without changes.

docs/content/docs/3.composables/2.query-collection-navigation.md renamed to docs/content/docs/3.utils/2.query-collection-navigation.md

File renamed without changes.

docs/content/docs/3.composables/3.query-collection-item-surroundings.md renamed to docs/content/docs/3.utils/3.query-collection-item-surroundings.md

File renamed without changes.

docs/content/docs/3.composables/4.query-collection-search-sections.md renamed to docs/content/docs/3.utils/4.query-collection-search-sections.md

File renamed without changes.

docs/content/docs/4.components/0.content-renderer.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: ContentRenderer
33
description: 'Takes your component from an AST to a wonderful template.'
44
---
55

6-
The `<ContentRenderer>` component renders a document coming from a query with [`queryCollections()`](/docs/composables/query-collection).
6+
The `<ContentRenderer>` component renders a document coming from a query with [`queryCollections()`](/docs/utils/query-collection).
77

88
> This component works only with `pages` collections.
99

docs/content/docs/5.deploy/1.cloudflare.md

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,14 @@ If you use the [Cloudflare Pages GitHub/GitLab integration][1]{target="_blank"}
1111

1212
In order to publish your project, you need to create a Cloudflare D1 database and connect it to your project.
1313

14-
[Learn how to create a D1 database](https://developers.cloudflare.com/d1/get-started/#2-create-a-database)
14+
- [Create a D1 database][d1]
15+
- Link it to your Cloudflare Pages project using the `DB` binding name
1516

16-
## Database
17-
18-
Unfortunately SQLite database is not supported in cloudflare environment and you should use another database.
19-
You can simply create a D1 database in cloudflare and use Content Module's D1 adapter.
20-
21-
- Use [Nuxt Hub](/docs/deploy/nuxthub) to create, connect and manage D1 database for you.
22-
- Or create a D1 database from Cloudflare dashboard and connect it to you project by creating a `wrangler.toml` file in project root. [Get started with Cloudflare D1][d1]
17+
Redeploy your project.
2318

19+
::tip
20+
Checkout the [**NuxtHub Integration**](/docs/deploy/nuxthub) to deploy your Nuxt Content project on your Cloudflare account with zero configuration and maximum performance.
21+
::
2422

2523
[1]: https://developers.cloudflare.com/pages/get-started/#connect-your-git-provider-to-pages
2624
[d1]: https://developers.cloudflare.com/d1/get-started/

docs/content/docs/5.deploy/2.nuxthub.md

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -5,39 +5,4 @@ navigation:
55
icon: i-simple-icons-nuxtdotjs
66
---
77

8-
Nuxt Content uses Nuxt deployment presets to adjust the build process for different hosting platforms. To deploy your Nuxt Content to Cloudflare, you can use the `cloudflare_pages`{lang="ts-type"} preset.
9-
10-
You can do that in two ways:
11-
12-
- By defining the `NITRO_PRESET`{lang="ts-type"} to `cloudflare_pages`{lang="ts-type"} when running the build process, like so:
13-
14-
```bash
15-
NITRO_PRESET=cloudflare_pages npm run build
16-
```
17-
18-
Or by updating your Nuxt configuration:
19-
20-
```bash
21-
"preset": "cloudflare_pages",
22-
```
23-
24-
If you use the [Cloudflare Pages GitHub/GitLab integration][1]{target="_blank"} Nuxt does not require configuration for presets.
25-
26-
## Database
27-
28-
Unfortunately sqlite database is not supported in cloudflare environment and you should use another database.
29-
You can simply create a D1 database in cloudflare and use Content Module's D1 adapter.
30-
31-
- You can simply use [Nuxt Hub][nuxt-hub] to create, connect and manage D1 database for you.
32-
- Or you can create it directly create a D1 database from Cloudflare dashboard and connect it to you project by creating a `wrangler.toml` file in project root. [Get started with Cloudflare D1][d1]
33-
34-
35-
36-
37-
38-
39-
40-
41-
[1]: https://developers.cloudflare.com/pages/get-started/#connect-your-git-provider-to-pages
42-
[nuxt-hub]: https://hub.nuxt.com/docs/features/database
43-
[d1]: https://developers.cloudflare.com/d1/get-started/
8+
TODO

0 commit comments

Comments
 (0)