In reference to Route Resolvers (Route Resolver - Prismic), if my Link Resolver routes are as follows, how would I accomplish it with a Route Resolver?
Thanks for posting this question to us it is a good question
Currently, you cannot achieve this with the Route Resolver. You have to use link resolver for that. We have already been tracking it as a feature request for future improvement.
On another note, I'm updating my SvelteKit site to use the latest Prismic APIs (@prismicio/helpers & @prismicio/client) following this article: Get Started with Svelte - Prismic
However, when visiting a page that uses SvelteKit's dynamic routing (ex: /[uid].svelte) an error is being thrown: Cannot read properties of undefined (reading 'find')
These pages use the getByUID() query method: const document = await Client.getByUID("page", uid);
The other normal pages, which use getSingle(), work fine.
If you do not define page params and declare uid variables, you need to use static uid for every page. For example: const document = await client.getByUID('page', 'hello-world')
Another way is to access the page parameter and query with it:
I'm doing it the second way. FYI, SvelteKit just changed their Loading Input function parameters: Docs • SvelteKit. So, the Prismic Svelte tutoring is now technically out of date
I tried testing using the first option you specified as well, stripping everything out of the page, and it still throws that error. So, I'm not sure if there's an issue with SvelteKit itself with the most recent update (1.0.0-next.232)? Maybe I'll test this on an earlier version.
On another note, I noticed that the docs for Svelte under Preview Drafts (Preview Drafts in Svelte - Prismic) are inaccurate. The redirect variable doesn't use the token and documentId variables and it just redirects to the home page.
I just confirmed that the same error is happening on SvelteKit v1.0.0-next.203. Everything works fine when using the older APIs: @prismicio/client v5 and prismic-dom.
Also, it's just the root [uid].svelte (/src/routes/[uid].svelte) file that's not working! My other dynamic routes live inside a folder and work fine. Ex: /routes/events/[uid].svelte
For the Previews, I was just commenting that the documentation is wrong. More info on how the resolvePreviewURL method is supposed to work would be helpful too.
Depoly app: yes, you are correct, however, the default config uses @sveltejs/adapter-auto (Docs • SvelteKit).
I can probably share my Github repo if that's helpful. Let me know what your user is.
Thanks for pointing this out. I will pass this on to my documentation team and make the necessary changes. resolvePreviewURL() directly returning the URL string. It also automatically reads the token and documentId URL parameters.