tinloof / sanity-kit

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Pages Navigator Custom Preview Issue

jckhxn opened this issue · comments

When attempting to customize the information returned by the pages navigator, I get the UUID (i.e pathname.current) instead of the value I'm attempting to return (which would be youtube.title in my schema)

How I'm customizing my preview
select: { title: "youtube.title", seasonNumber: "youtube.seasonNumber", episodeNumber: "youtube.episodeNumber", }, prepare(selection: { title: any; seasonNumber: any; episodeNumber: any }) { const { title, seasonNumber, episodeNumber } = selection; return { title: title, subtitle:S${seasonNumber} E${episodeNumber}, }; }, },

Upon investigation it is still returning the default value which is the pathname value.

Any suggestions? Thanks in advance.

Thanks for such a fantastic set of tools here!

I second this comment. When settings the name of the 'pathname' field to anything different (eg definePathname({ name: 'slug' })), the page navigator and "create new page" doesn't pick it up, instead defaulting to pathname. Could there be a setting in sanity.config.js that allows us to set this value? I'm trying to make this work in a pre-existing dataset :)

Screenshot 2024-05-09 at 2 54 03 PM Screenshot 2024-05-09 at 2 54 09 PM Screenshot 2024-05-09 at 2 54 13 PM

Any help would be much appreciated!

Any help would be much appreciated!

I have applied the same line in my schema, removing the field, then setting the URL. My document then had the field "slug". In your example you are only overwriting the existing pathname field from before. Hope that helps!