Slug schema #745
Closed
florian-lefebvre
started this conversation in
Proposal
Slug schema
#745
Replies: 1 comment
-
No longer relevant with the content layer |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Body
Summary
Add a way to compute data from slugs / ids in Content Collections.
Background & Motivation
Content Collections are powerful when it comes to the schema. Since it's just powered by Zod, you benefit from all its functionalities like
.refine
and.transform
.However, this only applies to entries data, not slugs/ids. . You may want to store data in slugs without duplicating it, like so:
Currently, you also have to either add
date
to the frontmatter (duplication) or make your own helpers to wrap Content Collections functions (eggetCollection
).Other example: i18n. It would be great to inject locale based on this path, eg
src/content/en/my-entry.md
.Goals
Example
Here is an example API:
For the following entry
the CollectionEntry type would be
Beta Was this translation helpful? Give feedback.
All reactions