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

Feature: Shared Astro base and Keystatic pathconfig (and data format) #1371

Open
tordans opened this issue Dec 4, 2024 · 0 comments
Open
Labels
enhancement New feature or request

Comments

@tordans
Copy link
Contributor

tordans commented Dec 4, 2024

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 #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
  })
@emmatown emmatown added the enhancement New feature or request label Dec 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants