Skip to content

feat(core): support multiple wildcard segments in collection paths (#340) - #1638

Open
frammawiliansyah wants to merge 1 commit into
Thinkmill:mainfrom
frammawiliansyah:feat/configurable-collection-path-340
Open

frammawiliansyah wants to merge 1 commit into
Thinkmill:mainfrom
frammawiliansyah:feat/configurable-collection-path-340

Conversation

@frammawiliansyah

@frammawiliansyah frammawiliansyah commented Oct 3, 2026 •

Copy link
Copy Markdown

Description

Resolves #340.
/claim #340

Allows collection path to configure multiple wildcard segments (e.g. src/content/blog/*/*). Each * wildcard corresponds to exactly one non-empty segment of the entry slug (e.g. en/my-first-post), enabling multi-segment organization (such as locale-partitioned or date-partitioned collections) while preserving deterministic static schema loading over the GitHub API without dynamic function callbacks.

Key Changes

  • Path Parsing (packages/keystatic/src/app/path-utils.ts): Added parseCollectionPathWildcards to parse collection paths with single or multiple wildcard segments (* or **) and return the expected segment count. Throws a clear error for invalid wildcard placement.
  • Slug Validation (packages/keystatic/src/form/fields/text/validateText.tsx & errors.ts): Updated slug validation to enforce the exact number of non-empty slash-separated segments corresponding to the wildcard count in the collection path.
  • Reader Resolution (packages/keystatic/src/reader/generic.ts): Updated list and read methods to filter entries by exact segment depth for multiple wildcard paths, preventing shallower or deeper matches.
  • Changeset & Tests (.changeset/multi-wildcard-collection-path.md, path-utils.test.ts, multi-wildcard.test.ts): Added unit test suites verifying path wildcard parsing, validation error formatting, and reader multi-segment filtering.

Impact & Architectural Notes

  • Backward Compatibility: Existing single * and ** collection configurations continue to behave identically.
  • Static Schema Determinism: Retains pure static string configuration compatible with GitHub REST API tree fetching without requiring runtime function execution.

Verification

  • pnpm check:types passed cleanly.
  • vitest run passed with 148 test files (1,287 tests passed).
  • pnpm build:packages completed successfully.

@changeset-bot

changeset-bot Bot commented Oct 3, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 95c99ef

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages
Name Type
@keystatic/core Minor
@keystatic/templates-astro Patch
@keystatic/templates-nextjs Patch
@keystatic/templates-remix Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enhancement: more configurable collection path

1 participant