Repository navigation
feat!: locator routes — publicPrefix, per-collection catch-all routes from createRoutes, shadowed-locator checks, and redirects when a published URL moves (3c(ii)) - #43
Merged
Conversation
🦋 Changeset detectedLatest commit: 4a0017d The changes in this PR will be included in the next version bump. This PR includes changesets to release 13 packages
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 |
|
Warning Review limit reachedEnable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. Next included review available in 59 minutes. View limit details
TanStack is on CodeRabbit Free, which includes PR summaries. Ask your admin to upgrade for code reviews.
|
cursor Bot
pushed a commit
that referenced
this pull request
Nov 6, 2026
…, shadowed locators, redirects on move) Co-authored-by: jherr <jherr@pobox.com>
cursor Bot
pushed a commit
that referenced
this pull request
Nov 6, 2026
Co-authored-by: jherr <jherr@pobox.com>
cursor
Bot
force-pushed
the
cursor/locator-routes-a931
branch
from
November 6, 2026 14:50
610d8e9 to
2a891d8
Compare
cursor
Bot
force-pushed
the
cursor/locators-a931
branch
from
November 6, 2026 14:50
29df10d to
31e8607
Compare
jherr
force-pushed
the
cursor/locator-routes-a931
branch
from
November 6, 2026 15:09
2a891d8 to
4a0017d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements part (ii) of cms-refactor-plan.md § Phase 3 (3c), plus rules 6 and 7 of § "Decided: nested slugs": no shadowing of app routes, and renames write a redirect.
Merge chain: step 21 of 24. Base:
main. Merge it right after #38. The branch ismain3b4a112, then one commit for each PR before this one in the merge order, then this PR's own commit2a891d8(tree4f31216).What
Collection.publicPrefix. It takes a path such as'/docs', or'/'for the site root, and serves each document at{prefix}/{locator}.path. An explicitpathstill wins.documentPath(collection, doc, id).documentPath,publicPrefixOf,normalizePublicPrefix;/definition:normalizePublicPrefix,SHADOWED_LOCATORS_KEY,ShadowedLocators,LocatorInput,LocatorStrategy.createRoutes. Each prefixed collection gets a generated{prefix}/$route.get({ collection, locator })first. If nothing matches, it tries the redirects collection, then returns a 404.collectionskey takestrue,false,['docs']or{ docs: false | './docs.$.tsx' }. It's separate from R2'srenderers.'/'takes over/$fromnotFound.createRoutesthrows if a catch-all collides with another route, or if a prefix starts inside the admin or API routes.VALIDATION_FAILED. A generated slug steps past it instead, e.g.api-2. ThetanstackCms()plugin passes the map of shadowed segments to builds. Without the plugin, core falls back to the checks it can make on its own.writeDocumentis the single path for commit, approve and scheduled publish. When a published document's URL changes, it writes a 301 from the old URL in the same transaction.examples/astro-starlight-after, its migration script, the skill andfrom-astro-starlight.md.nested: trueslug under/docs./docs/<path>.$'in a path like/docs/$was being read as a replacement pattern. The fix was made here while feat(ui-react)!: createRoutes(definition, spec) replaces cmsVirtualRoutes(options) #28 was on hold. On the merge chain it lands at this step, after feat(ui-react)!: createRoutes(definition, spec) replaces cmsVirtualRoutes(options) #28.No schema migration. Redirects are ordinary documents, so nothing has to be ordered against 3c(i)'s v17/v9 or 4b's v16/v8.
Merge of #28: conflicts and resolutions (for replay)
scripts/codemods/index.ts.claude/skills/payload-to-tanstack-cms/SKILL.md,docs/migration/from-sanity.mdreadDocumentAsdocs/schema/building-pages.mdstarters/contact-cards,starters/ecommerce-storefrontcms.config.tsstarters/documentation-kb,starters/multi-tenant-fleetcms.config.ts…As(ctx)reads. 3c(i)'slocatorStrategymoves into theircms.definition.ts.app/base/src/model.tscollection-runtime.ts, wherecurrentSession()is gone.docs/deployment/upgrading.mdUpgrading numbering. #42 had resolved the same conflict the other way. The merge chain settles a single sequence: upgrading steps are numbered in merge order, and this PR's step is 30.
Scratch merge with
origin/main: 25 conflicts, all caused by the squash merge of R1a (#22). That squash commit has the same tree ascursor/explicit-roles-6828, which is already in this branch's history, so the branch side was taken everywhere.Breaking changes
paths such as/post/${slug}./$.createRoutesand the definition also throw in the new cases described above.pagelinks. When thepagecollection has a prefix, home, nav and the docs sidebar link to locator URLs./p/$idstill serves pages.slugfield and/docs/<slug>URLs.How verified
tests/locator-routes.test.ts(9 tests):pathwinning over it;collectionsspec key./docs/guides/getting-started) and a redirect after a rename.b704ecc, which merges610d8e9intoorigin/main3b4a112.pnpm install --frozen-lockfilepnpm test:ci(174 tasks)@tanstack/cms-api:test:oxlintfails. Core 660, ui-react 99, every starter passes.test:dts/test:definitionstest:dialectsqueryDocumentsmatch comes from a storage-level call, not the deprecated verb.test:scriptsThe first full run caught two failures, both fixed in
610d8e9:definition-splitcodemod's export list was missing the new/definitionexports;createRouteserror messages.One base E2E test failed once, after a dev-server "Failed to fetch", and passed on three later runs.
Assumptions (conservative defaults where the plan gives none)
publicPrefixis opt-in, so no existing URL changes.pathwins over it./docs, not at the site root.indexroute still owns/.collectionsfollows thepublicsetting by default.Divergence from plan
hrefis added inroutes/index.tsx,routes/p.$id.tsxandroutes/post.$id.tsx. R2 (feat(core, ui-react)!: block renderers move out of blockTypes into the createRoutes renderers module (R2) #31/feat(core, ui-react)!: field inputs and cells move out of the config into the renderers module (R2 fields) #32) edits the same files; on the merge chain those edits are already resolved.Follow-ups
Merge chain (local verification, CI down)
This PR's commits are squashed into one commit on the linear merge chain. That commit holds this PR's own changes, resolved against every PR before it, with the integration rehearsal's fixes for this PR applied. Seven conflicts, resolved as in the rehearsal:
vite.ts,virtual-routes.tsand its test,internal.ts,cms-ui-react.md, and the StarlightMIGRATION.mdand migration test.routes/collection.$.tsximports../app-renderers, which #31 added. Its upgrading section is step 30. The commit was replayed from8bd2116.The chain tip's tree is exactly the integration rehearsal plus #46 (
c4e6d7c), and the tip passes the full local suite. I simulated merging every PR in order, with a merge commit or a fast-forward at each step, and every step is clean. A plain squash of the next PR would conflict, because the squash commit isn't an ancestor of the next branch. To squash instead, first rebase the branch's one commit onto the newmain; that rebase is always clean.