N
Nuxt3mo ago
Kumzy

zod editor nuxt/content latest release

Hello, with the latest release of nuxt/content, it says to change the import for zod but when doing so, we no longer have access to the editor
dark: z.string().editor({ input: 'media' }),
dark: z.string().editor({ input: 'media' }),
As the type is declared in nuxt/content. How to fix that? Regards
5 Replies
kapa.ai
kapa.ai3mo ago
Hi @Kumzy. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- With the latest release of @nuxt/content, the recommended way to use Zod schemas—including the .editor() method for Studio form customization—is to import z directly from @nuxt/content, not from the standalone zod package. The z object provided by @nuxt/content extends Zod with the .editor() method and other helpers needed for Studio integration. Example:
import { defineContentConfig, defineCollection, z } from '@nuxt/content'

export default defineContentConfig({
collections: {
posts: defineCollection({
type: 'page',
source: 'blog/*.md',
schema: z.object({
dark: z.string().editor({ input: 'media' }),
// ...other fields
}),
}),
},
})
import { defineContentConfig, defineCollection, z } from '@nuxt/content'

export default defineContentConfig({
collections: {
posts: defineCollection({
type: 'page',
source: 'blog/*.md',
schema: z.object({
dark: z.string().editor({ input: 'media' }),
// ...other fields
}),
}),
},
})
If you import z from zod directly, you will not have access to .editor(). Always use the z import from @nuxt/content for schema definitions in your content.config.ts file. This is documented in the official guides and changelogs: - Studio Form Customisation - Form editor documentation - Custom Inputs Mapping If you are already importing from @nuxt/content and still do not see .editor(), ensure you are using the latest version of @nuxt/content (v3 or above), as this feature is only available in recent releases. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai3mo ago
<@238709222005669888> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
Kumzy
KumzyOP3mo ago
@kapa.ai You can fetch the release note from there https://github.com/nuxt/content/releases/tag/v3.7.0 and you will see that the re-export of z is deprecated
kapa.ai
kapa.ai3mo ago
Let me check the knowledge base for you again. One moment! :books: ---------------------- You're correct that in the v3.7.0 release notes, the re-export of z from @nuxt/content is marked as deprecated. However, based on the knowledge sources provided, there is no explicit information about how to use the .editor() method for Studio form customization with the new recommended Zod import method after this deprecation. All current documentation and examples—including those for custom Studio inputs and the .editor() method—still show importing z from @nuxt/content and using .editor() directly on Zod schemas:
import { defineContentConfig, defineCollection, z } from '@nuxt/content'

export default defineContentConfig({
collections: {
posts: defineCollection({
type: 'page',
source: 'blog/*.md',
schema: z.object({
dark: z.string().editor({ input: 'media' }),
}),
}),
},
})
import { defineContentConfig, defineCollection, z } from '@nuxt/content'

export default defineContentConfig({
collections: {
posts: defineCollection({
type: 'page',
source: 'blog/*.md',
schema: z.object({
dark: z.string().editor({ input: 'media' }),
}),
}),
},
})
Studio Form Customisation
Custom Inputs Mapping The knowledge sources do not provide updated guidance for using .editor() with a direct zod import or an alternative approach after the deprecation of the z re-export. If you are affected by this deprecation and need .editor(), the official documentation and changelogs do not yet describe a new method for extending Zod schemas with Studio metadata. In summary:
- The .editor() method is only documented as available on the z import from @nuxt/content. - The knowledge sources do not explain how to use .editor() if you import Zod directly. - If the deprecation blocks your workflow, you may need to wait for updated documentation or guidance from the Nuxt Content team. I'm sorry, but the knowledge sources do not contain enough information to answer how to use .editor() with the new Zod import method after the deprecation of the z re-export. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai3mo ago
<@238709222005669888> Kapa.ai is still learning and improving, please let me know how I did by reacting below.

Did you find this page helpful?