From c6c27b893e4d05abc822fc0bd006ecf8da40234f Mon Sep 17 00:00:00 2001 From: Cody Olsen Date: Mon, 13 Nov 2023 17:03:47 +0100 Subject: [PATCH] fix(csm): allow passing a string `path` --- src/csm/createEditUrl.ts | 4 +++- src/csm/types.ts | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/csm/createEditUrl.ts b/src/csm/createEditUrl.ts index 8bc361c1..01496a3f 100644 --- a/src/csm/createEditUrl.ts +++ b/src/csm/createEditUrl.ts @@ -32,7 +32,9 @@ export function createEditUrl(options: CreateEditUrlOptions): `${StudioBaseUrl}$ // eslint-disable-next-line no-warning-comments // @TODO allow passing draft prefixed IDs, to better open the right perspective mode const id = getPublishedId(_id) - const stringifiedPath = studioPath.toString(jsonPathToStudioPath(path)) + const stringifiedPath = Array.isArray(path) + ? studioPath.toString(jsonPathToStudioPath(path)) + : path // eslint-disable-next-line no-warning-comments // @TODO Using searchParams as a temporary workaround until `@sanity/overlays` can decode state from the path reliably diff --git a/src/csm/types.ts b/src/csm/types.ts index 85c2d1dc..85d29d0a 100644 --- a/src/csm/types.ts +++ b/src/csm/types.ts @@ -67,7 +67,7 @@ export interface CreateEditUrlOptions { tool?: string id: string type: string - path: ContentSourceMapParsedPath + path: ContentSourceMapParsedPath | string } /** @alpha */