Current state
Currently, the path is always static except for the slug, specified by slugField.
The problem
Projects often require more custom paths, e.g.: locales, publish date
Proposal
Make the collection config an intersection like so (pseudocode):
type Collection = { /* base props */}
& (
{
path: string // with * validation
slugField: keyof fields
}
| {
path: (fields: Record<string, any>) => string // with * validation
slugField: keyof fields // might not be required, we could manually specify the field by interpolation instead
}
)
Examples
Locales
export default defineConfig({
// ...
collections: {
blog: collection({
label: "Blog",
path: ({ locale }) => `src/content/blog/${locale}/*`
schema: {
// ...
locale: fields.text({ label: "Locale" }) // could be a relationship, whatever
}
})
}
})
Publish date
export default defineConfig({
// ...
collections: {
blog: collection({
label: "Blog",
path: ({ publishDate }) => `src/content/blog/${publishDate}.*`
schema: {
// ...
publishDate: fields.date({ label: "Published date" })
}
})
}
})
Current state
Currently, the path is always static except for the slug, specified by
slugField.The problem
Projects often require more custom paths, e.g.: locales, publish date
Proposal
Make the collection config an intersection like so (pseudocode):
Examples
Locales
Publish date