-
-
Notifications
You must be signed in to change notification settings - Fork 642
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Content typings support roadmap #1057
Comments
This solution no longer works, because See nuxt/nuxt#14440 |
* cause by useAsyncData track nuxt/content/issues/1057
* cause by useAsyncData track nuxt/content/issues/1057
Hello, this issue is quite old but as it is still referenced from the docs I wondered if it was the right place to discuss a proposed feature to improve the typings on Nuxt content. I love the concept of the types from query content params but in my case I am using dynamic parameters to the content module so it may make this tricky (not impossible though). What I was wondering was allowing users to lean on validators like I was wondering about adding a hook such as The resultant hook would combine the returned type with const pageSchema = z.object({
navigation: z.object({
nextBtn: z.string()
})
})
export default function () {
return queryContent('some-param').hook((c) => pageSchema.parse(c))
} This hook would be evaluated just before queryContent is evaluated. This allows chaining of this using the I would like to add this what do the team think? This could also be extended to add a parameter before for the hook name. That way in future if there was to be other hook points we could support them? |
As for now, if you want to have proper typings when using
queryContent
; you should pass an argument to it that extends ParsedContentMeta.This is obviously not the final approach we want to provide with @nuxt/content.
The next step for us is to generate types in development based on the actual data from these files.
Until we reach that point, the recommended approach is to use type augmentation, which will be the easiest "change" to replace in your codebase once that type generation feature reaches release.
The text was updated successfully, but these errors were encountered: