keystatic
keystatic copied to clipboard
Feature: Shared Astro `base` and Keystatic `path`config (and data format)
In Astro 5 the new content collection loaders become the new default.
See https://docs.astro.build/en/guides/upgrade-to/v5/#updating-existing-collections for how to migrate
Similar to https://github.com/Thinkmill/keystatic/issues/336 it would be great to have native support in Keystatic to make it easier to manage the Astro and Keystatic configs.
In this case, the shared information is where the data is stored and what format the data has.
My current solution is this:
In my keystatic config, export the path, for example:
export const contentBaseSubprojects = '/src/content/subprojects'
export const keystaticSubprojectsConfig = collection({
label: 'Teilprojekte',
slugField: 'title',
path: `${contentBaseSubprojects}/*`,
format: { contentField: 'content' },
schema: {
…
In my astro content config, use the same path:
export const astroSubprojectsDefinition = defineCollection({
loader: loader(contentBaseSubprojects, 'mdx'),
schema: ({ image }) =>
…
Ideally, I could so something like…
export const astroSubprojectsDefinition = defineCollection({
loader: astroKeystaticLoader(keystaticSubprojectsConfig),
schema: ({ image }) =>
…
…which would return something like…
return glob({
base: PATH, // PATH = keystatic.collection.path (without the `/*`)
pattern: `**\/[^_]*.${FORMAT}`, // FORMAT = keystatic.collection.format
})