Feature: Shared Astro `base` and Keystatic `path`config (and data format)

Open
#1,371 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
typescript
Domain
content, tooling

Research direction

Start by tracing the Keystatic collection configuration and Astro's defineCollection loader entry point described in the issue, then inspect how glob receives the base path and file pattern. The work is done when one shared collection config supplies the storage path and content format to Astro without duplicating those values.

Written by the indexing model from the issue text.

Description

enhancement

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
  })
Dominant language
TypeScript
Stars
2.4k
Forks
159
Avg merge
21h 41m
Merged PRs (30d)
2

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Thinkmill/keystatic

All issues in Thinkmill/keystatic

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.