Collection Sources
Nuxt Content provides several ways to import content files into your collection. You can configure the source by using the source property within defineCollection:
import { defineCollection, defineContentConfig } from '@nuxt/content'
export default defineContentConfig({
collections: {
docs: defineCollection({
source: '**',
type: 'page'
})
}
})
source
The source property can be defined as either a string (following a glob pattern) or an object, allowing more detailed source configuration for your target directory and files within the content folder.
Example:
source: '**includes all files within the content directory and its subdirectories.source: '**/*.md'includes allMarkdownfiles within the content directory and its subdirectories.source: 'docs/**/*.yml'includes allYMLfiles within thecontent/docsand its subdirectories.source: '**/*.{json,yml}'includesJSONorYMLfile within the content directory and all its subdirectories.source: '*.json'includes onlyJSONfiles located directly within the content directory, excluding any subdirectories.
include
Glob pattern of your target repository and files in the content folder.
exclude
Glob patterns to exclude content from the import.
prefix
This configuration only applied for page type with 1-to-1 relationship between content files and pages on your site.
It represents the path prefix (base URL) of the corresponding page on the website.
cwd
Root directory for content matching.
repository
External source representing a remote git repository URL (e.g., https://github.com/nuxt/content)
authToken
Authentication token for private repositories (e.g., GitHub personal access token).