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

.json files prefixed with underscores don't get ignored inside content collections on build #7154

Closed
1 task
Princesseuh opened this issue May 21, 2023 · 5 comments · Fixed by #7246, #7268, #7611 or ag-grid/ag-charts#492
Assignees
Labels
- P3: minor bug An edge case that only affects very specific usage (priority)

Comments

@Princesseuh
Copy link
Member

What version of astro are you using?

2.5.1

Are you using an SSR adapter? If so, which one?

N/A

What package manager are you using?

pnpm

What operating system are you using?

macOS

What browser are you using?

Arc

Describe the Bug

I have the following folder structure:

src/
└─ content/
   ├─ blog/
   │   └─ my-article/
   │     ├─ my-article.md
   │     └─ _some-data.json
   └─ config.ts

(I refer to _some-data.json from my layout through some arcane way that does not matter in this context.)

In dev, this works, _some-data.json is ignored, as files prefixed with underscores should be. In build however, _some-data.json is being passed through the Zod schema as if it was a file that needs to respect the blog schema. I would like for this file to be completely ignored, like it is in build.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-nxjeur?file=src/content/blog/my-article/my-article.md,src/pages/index.astro,src/content/blog/my-article/_my-data.json&on=stackblitz

Participation

  • I am willing to submit a pull request for this issue.
@bholmesdev bholmesdev self-assigned this May 21, 2023
@bholmesdev bholmesdev added - P3: minor bug An edge case that only affects very specific usage (priority) content-collections labels May 21, 2023
@birtles
Copy link

birtles commented May 23, 2023

I believe this is a regression from 2.5. This used to work with 2.4.

@Princesseuh
Copy link
Member Author

I believe this is a regression from 2.5. This used to work with 2.4.

Yes, 2.5 added data collections. Before that, JSON files were never processed, underscore or not

@thisistonydang
Copy link
Contributor

Hi @bholmesdev, I just updated to Astro 2.5.6 and seem to be having a similar, but slightly different issue.

I have the following folder structure:

src/
└─ content/
   ├─ blog/
   │   └─ my-article/
   │     ├─ my-article.md
   |     ├─ _my-data-directory/
   │       └─ some-data.json
   └─ config.ts

My json data (some-data.json) is NOT prefixed with an underscore, however it is in a directory (_my-data-directory/) that is prefixed with an underscore.

I am getting the same issue where the build fails because it does not match the collection schema. May I ask if this is the intended behavior and it is required for json files to be always prefixed with an underscore even if it's already in a directory prefixed with an underscore?

@bholmesdev
Copy link
Contributor

Ah, definitely an oversight. I see what we missed @tonydangblog. Reopening to make that fix

@Princesseuh
Copy link
Member Author

Princesseuh commented Jul 9, 2023

This issue is back since 2.7.1. Highly likely it's this commit: 478cd9d

cc @bholmesdev

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment