Skip to content
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

Inconsistent placement of custom fields form the .md files #2856

Open
iBobik opened this issue Nov 19, 2024 · 1 comment
Open

Inconsistent placement of custom fields form the .md files #2856

iBobik opened this issue Nov 19, 2024 · 1 comment
Labels
bug Something isn't working v3

Comments

@iBobik
Copy link

iBobik commented Nov 19, 2024

Environment

Version

3.0.0-alpha.6

Reproduction

https://codesandbox.io/p/devbox/brave-bogdan-8myc2y?workspaceId=11463712-f2b6-4ff2-abfc-9afdf4b3cb02

Description

When I place custom field in the front matter:

---
title: Example article
image: /images/products/test.jpeg
---

define schema for it (like recommanded in the docs):

  products: defineCollection({
    type: 'page',
    source: 'products/*.md',
    schema: z.object({
      image: z.string(),
    }),
  }),

Typing tells me the field is on the object root:

Image

But it actually is accesible in the meta subobject:

meta.image: /images/products/test.jpeg
image:

Even if typing does not expect it there:

Image

@iBobik iBobik added bug Something isn't working v3 labels Nov 19, 2024
@farnabaz
Copy link
Member

This is related to cached data in .data/content directory. The next version will respect collection changes and will clear cache automatically.

But for now in alpha.6 you can remove .data/content directory in your project and restart Nuxt to force a re-index.
This will solve the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working v3
Projects
None yet
Development

No branches or pull requests

2 participants