Configuration

You can configure Nuxt Content with the content property in your nuxt.config.js|ts file.


nuxt.config.ts
export default defineNuxtConfig({  content: {    // My custom configuration  }})

base

  • Type: String
  • Default: '/_content'

Base route that will be used for content api.

nuxt.config.ts
export default defineNuxtConfig({  content: {    base: '/_content'  }})

watch

  • Type: Object | false
  • Default: { port: 4000, showUrl: true }

Disable content watcher and hot content reload.

The watcher is a development feature and will not be included in production.

Enabled
export default defineNuxtConfig({  content: {    watch: {      ws: {        port: 4000,        showUrl: true      }    }  }})
Disabled
export default defineNuxtConfig({  content: {    watch: false  }})

ws options

OptionDefaultDescription
port4000Select the port used for the WebSocket server.
showUrlfalseToggle URL display in dev server boot message.

sources

  • Type: Array<Object | String>
  • Default: ['content']

Define different sources for contents.

Contents can located in multiple places, in multiple directories or in remote git repositories.

nuxt.config.ts
export default defineNuxtConfig({  content: {    sources: [      'content',      {        name: 'fa-ir',        prefix: '/fa', // All contents inside this source will be prefixed with `/fa`        driver: 'fs',        // ...driverOptions        base: resolve(__dirname, 'content-fa') // Path for source directory      }    ]  }})

ignores

  • Type: string[] | object[]
  • Default: ['\\.', '-']

List of ignore pattern that will be used for excluding content from parsing and rendering.

nuxt.config.ts
export default defineNuxtConfig({  content: {    ignores: [      'ghost'    ]  }})

markdown

This module uses remark and rehype under the hood to compile markdown files into JSON AST that will be stored into the body variable.

To configure how the module will parse Markdown, you can use markdown.remarkPlugins and markdown.rehypePlugins in your nuxt.config.ts file:

nuxt.config.ts
export default defineNuxtConfig({  content: {    markdown: {      // Object syntax can be used to override default options      remarkPlugins: {        // Override remark-emoji options        'remark-emoji': {          emoticon: true        },        // Disable remark-gfm        'remark-gfm': false,        // Add remark-oembed        'remark-oembed': {          // Options        }      },      // Array syntax can be used to add plugins      rehypePlugins: [        'rehype-figure'      ]    }  }})

Here is a list of plugins @nuxt/content is using by default.

When adding a new plugin, make sure to install it in your dependencies.

mdc

  • Type: Boolean
  • Default: true

Whether MDC syntax should be supported or not.

toc

  • Type: Object
  • Default
    {  depth: 2,  searchDepth: 2}

Control behavior of Table of Contents generation.

  • depth: Maximum heading depth to includes in the table of contents.
  • searchDepth: Maximum depth of nested tags to search for heading.

tags

  • Type: Object

Tags will be used to replace markdown components and render custom components instead of default ones.

nuxt.config.ts
export default defineNuxtConfig({  content: {    markdown: {      tags: {        p: 'MyCustomParagraph'      }    }  }})

highlight

  • Type: false | Object

Nuxt Content uses Shiki to provide syntax highlighting for ProseCode and ProseCodeInline.

highlight options

OptionTypeDescription
themeShikiTheme or Record<string, ShikiTheme>The color theme to use.
preloadShikiLang[]The preloaded languages available for highlighting.

highlight.theme

Theme can be specified by a single string but also supports an object with multiple themes.

This option is compatible with Color Mode module.

If you are using multiple themes, it's recommended to always have a default theme specified.

export default defineNuxtConfig({  content: {    highlight: {      // Theme used in all color schemes.      theme: 'github-light'      // OR      theme: {        // Default theme (same as single string)        default: 'github-light',        // Theme used if `html.dark`        dark: 'github-dark',        // Theme used if `html.sepia`        sepia: 'monokai'      }    }  }})

yaml

  • Type: false | Object
  • Default: {}

Options for yaml parser.

  • Type: false or Object
  • Default: true

Configure the navigation feature.

Can be set to false to disable the feature completely.

OptionTypeDescription
fieldsstring[]A list of fields to inherit from front-matter to navigation nodes.

locales

  • Type: Array<String>
  • Default: []

List of locale codes. This codes will be used to detect contents locale.

defaultLocale

  • Type: String
  • Default: undefined

Default locale for top level contents. Module will use first locale code from locales array if this option is not defined.

documentDriven

  • Type: Boolean | Object
  • Default: false

Toggles the document-driven mode.

false will disable the feature completely.

true will enable the feature with these defaults:

Document-driven defaults
{  // Will fetch navigation, page and surround.  navigation: true,  page: true,  surround: true,  // Will fetch `content/_theme.yml` and put it in `globals.theme` if present.  globals: {    theme: {      where: {        _id: 'content:_theme.yml'      },      without: ['_']    }  },  // Will use `theme` global to search for a fallback `layout` key.  layoutFallbacks: ['theme'],  // Will inject `[...slug].vue` as the root page.  injectPage: true}

documentDriven options

OptionTypeDescription
pageBooleanEnables the page binding, making it globally accessible.
navigationBooleanEnables the navigation binding, making it globally accessible.
surroundBooleanEnables the surround binding, making it globally accessible.
globalsObject | BooleanA list of globals to be made available globally.
layoutFallbacksstring[]A list of globals key to use to find a layout fallback.
injectPagebooleanInject [...slug].vue pre-configured page