-
-
Notifications
You must be signed in to change notification settings - Fork 657
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
Are some of frontmatter attributes moved to meta key? #3073
Comments
I am also wondering about this. Not yet versed in Nuxt, learning at the moment, but tried to add "publishedAt" field and was wondering why I could not add it to the queryCollection.select() method.(was returning "ssr:error [nuxt] [request error] [unhandled] [500] no such column: "publishedAt" - should this be a string literal in single-quotes?" error) Turns out the field was under meta key. I am working through a tutorial that uses V2 of nuxt/content, which instructs me to just add the publishedAt field in the frontmatter in yaml format. However, I could not find info in the docs about rules that automatically nests non-native keys inside meta key, or how to select or order by such nested fields, so I am stuck at the moment. My Code:
The frontmatter of 'first.md' file.
|
If you want the link and external to appear in the main object, you must define a schema, all fields that are not defined in the schema will appear in It seems to me that such a schema is sufficient for your example import { defineCollection, defineContentConfig, z } from '@nuxt/content'
export default defineContentConfig({
collections: {
content: defineCollection({
type: 'page',
source: '**',
schema: z.object({
external: z.boolean(),
link: z.string()
})
})
}
}) |
@mateusznarowski Thank you for your clarification! Are there plans for this detail to be added to documentation? (That unspecified frontmatter keys will be automatically nested inside meta key) |
It is already described in the documentation https://content.nuxt.com/docs/collections/types |
But it's not described how to add them in frontmatter https://content.nuxt.com/docs/files/markdown#frontmatter ? |
I guess keeping non-schema fields, created a bit of confusing. Lets put it this way, Schemas are the source of truth for collections and contents. If you want to use a field/data, should be defined in the collection's schema. By design, meta field only exists to preserve content as whole and not lose any data. |
@victor-ponamariov , technically speaking, @mateusznarowski did show that, as far as the Nuxt Content doc as a whole is concerned, it is described. I do agree with you that a brief heads-up in the frontmatter section could be helpful for Nuxt newbies like me.
|
FWIW I also didn't understand how to solve this after reading the Alpha docs many, many times. I feel like a great addition to the Collection Docs would be:
I personally thought I'd done my zod-ing properly, but was like "WTF why are my types broken and why is everything under |
When moving to Nuxt Content 3 I found out that when I queried collection, my previous custom frontmatter attributes were empty. Then I checked the collection via dev tools and found out that they are under meta now
But I couldn't find anything about this in docs, only "native" parameters https://content.nuxt.com/docs/files/markdown#native-parameters.
If I miss it, could you please guide me where it is. If I don't miss it, then I can try to make the first PR ever to update the docs, but I'm not a native English speaker and will be able to only check grammar :)
The text was updated successfully, but these errors were encountered: