Skip to content

Latest commit

 

History

History
270 lines (200 loc) · 6.12 KB

3.configuration.md

File metadata and controls

270 lines (200 loc) · 6.12 KB
title description icon
Configuration
You can configure Nuxt Content with the content property in your nuxt.config.js|ts file.
heroicons-outline:adjustments
export default defineNuxtConfig({
  content: {
    // My custom configuration
  }
})

base

  • Type: String{lang=ts}
  • Default: '/_content'{lang=ts}

Base route that will be used for content api.

export default defineNuxtConfig({
  content: {
    base: '/_content'
  }
})

watch

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

Disable content watcher and hot content reload.

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

::code-group

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

::

ws options

Option Default Description
port 4000 Select the port used for the WebSocket server.
showUrl false Toggle URL display in dev server boot message.

sources

  • Type: Array<Object | String>{lang=ts}
  • Default: ['content']{lang=ts}

Define different sources for contents.

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

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[]{lang=ts}
  • Default: ['\\.', '-']{lang=ts}

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

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:

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{lang=ts}
  • Default: true{lang=ts}

Whether MDC syntax should be supported or not.

toc

  • Type: Object{lang=ts}
  • Default
    {
      depth: 2,
      searchDepth: 2
    }

Control behavior of Table of Contents generation.

  • depth{lang=ts}: Maximum heading depth to includes in the table of contents.
  • searchDepth{lang=ts}: Maximum depth of nested tags to search for heading.

tags

  • Type: Object{lang=ts}

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

export default defineNuxtConfig({
  content: {
    markdown: {
      tags: {
        p: 'MyCustomParagraph'
      }
    }
  }
})

highlight

  • Type: false | Object{lang=ts}

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

highlight options

Option Type Description
theme ShikiTheme or Record<string, ShikiTheme> The color theme to use.
preload ShikiLang[] 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{lang=ts}
  • Default: {}{lang=ts}

Options for yaml parser.

navigation

  • Type: false or Object{lang=ts}
  • Default: true{lang=ts}

Configure the navigation feature.

Can be set to false to disable the feature completely.

navigation options

Option Type Description
fields string[] A list of fields to inherit from front-matter to navigation nodes.

locales

  • Type: Array<String>{lang=ts}
  • Default: []{lang=ts}

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

defaultLocale

  • Type: String{lang=ts}
  • Default: undefined{lang=ts}

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