fix(admin): use collection urlPattern for preview button fallback URL (#181)

* fix(admin): use collection urlPattern for preview button fallback URL

The preview button hardcoded fallback URLs as /${collection}/${slug},
ignoring the collection's urlPattern setting. Collections with custom
URL patterns (e.g. urlPattern: "/biljke/{slug}" on a "biljka" collection)
would open a 404 instead of the correct page.

Thread urlPattern through the manifest and use it in the ContentEditor
preview fallback.

Fixes #167

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

Signed-off-by: Filip Ilic <ilic.filip@gmail.com>

* chore: add changeset for preview URL pattern fix

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

Signed-off-by: Filip Ilic <ilic.filip@gmail.com>

---------

Signed-off-by: Filip Ilic <ilic.filip@gmail.com>
Co-authored-by: Matt Kane <mkane@cloudflare.com>
This commit is contained in:
Filip Ilić
2026-04-04 21:00:28 +02:00
committed by GitHub
parent 3674d4857a
commit 9d10d2791f
5 changed files with 16 additions and 2 deletions

View File

@@ -28,6 +28,7 @@ export interface ManifestCollection {
labelSingular: string;
supports: string[];
hasSeo: boolean;
urlPattern?: string;
fields: Record<
string,
{

View File

@@ -1180,6 +1180,7 @@ export class EmDashRuntime {
labelSingular: collection.labelSingular || collection.label,
supports: collection.supports || [],
hasSeo: collection.hasSeo,
urlPattern: collection.urlPattern,
fields,
};
}