-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Added generateId option for file loader #12308
base: main
Are you sure you want to change the base?
Added generateId option for file loader #12308
Conversation
|
This is great. Thanks! Could you add a changeset that can form the basis for updated docs? |
Sure will do it later today 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR is blocked because it contains a minor
changeset. A reviewer will merge this at the next release if approved.
@ascorbic I've added the changeset, is this sufficient? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @marceloverdijk for the contribution!
There are three things I ask you to implement:
- Change the changeset to be
patch
. Content Layer is experimental, so we can land new APIs underpatch
. - Create at least a new test to verify that your implementation works. Let me know if you need any help with that. You can start from here
it('Returns `file()` loader collection', async () => { - Docs. For now our docs are here:
astro/packages/astro/src/@types/astro.ts
Lines 2213 to 2242 in 7680349
* The `file()` loader creates multiple entries from a single local file. Use this when all your entries are stored in an array of objects. * * ```ts {3,8,19} * // src/content/config.ts * import { defineCollection, z } from 'astro:content'; * import { glob, file } from 'astro/loaders'; * * const blog = defineCollection({ * // By default the ID is a slug generated from * // the path of the file relative to `base` * loader: glob({ pattern: "**\/*.md", base: "./src/data/blog" }), * schema: z.object({ * title: z.string(), * description: z.string(), * pubDate: z.coerce.date(), * updatedDate: z.coerce.date().optional(), * }) * }); * * const dogs = defineCollection({ * // The path is relative to the project root, or an absolute path. * loader: file("src/data/dogs.json"), * schema: z.object({ * id: z.string(), * breed: z.string(), * temperament: z.array(z.string()), * }), * }); * * export const collections = { blog, dogs };
Let me know if I can be of any help with docs here! 🙌 |
Background: withastro/roadmap#1045
Changes
pnpm exec changeset
Testing
Docs
/cc @withastro/maintainers-docs for feedback!