Nuxt content v2 to v3 migration issue with frontmatter fields

Nuxt

Today i faced an issue when migration from nuxt-content v2 to v3.5.1. There's documentation, but it doesn't clearly explain how frontmatter fields are handled.

Steps for Migration

Create content.config.ts with the following contents:

import { defineContentConfig, defineCollection, z } from '@nuxt/content'

export default defineContentConfig({
  collections: {
    content: defineCollection({
      type: 'page',
      source: '**/*.md',
    }),
    blog: defineCollection({
      type: 'page',
      source: 'blog/**/*.md',
      schema: z.object({
        date: z.string(),
        tag: z.string(),
      }),
    }),
  },
})

You need to adjust this config for your needs, in my case there was an issue accessing frontmatter fields, like: tag, date:

---
title: 'Blog post'
tag: 'Nuxt'
date: '2025-06-09T17:16:27.370Z'
---

tag, date were inaccessible when using queryCollection:

const query = queryCollection('blog')
  .limit(limit.value)
  .skip(limit.value * (currentPage.value - 1))
  .order('date', 'DESC')
  .where('tag', '=', 'blabla')

If you don't override schema for the Blog collection - it won't work, those fields will be nested under the meta property of the document.

I spent few hours to figure this out 😂