Sveltekit Link Resolver Error

Describe your question/issue in detail

Hello, thank you for your help. I am building a SvelteKit based site and having trouble understanding how to properly config the routes.

I have a menu with one level deep, lets say:

home
contact us

  • write us
  • directory

The "directory" and "write us" page have a relationship of the type category called "contact-us"

I noticed that I can access this pages either way:

https://mysite.com/directory
or
https://mysite.com/contact-us/directory

However, I want /contact-us/directory to be the only way to access this page.

--

My current file structure:

[[preview==preview]]

  • [category]
    -- [uid]
    ---+page.svelte
    ---+page.server.js
    -[uid]
    --+page.svelte
    --+page.server.js

My prismicio file config:

const routes = [
	{
		type: 'page',
		uid: 'home',
		path: '/'
	},
	{
		type: 'page',
		path: '/:uid',
	},
];

After reading the documentation, https://prismic.io/docs/route-resolver#route-resolve, I have tried a few ways of adding the route with a resolver :

	{
		type: 'page',
		path: '/:category/:uid',
              resolvers:{
                 category: 'category'
              }
	},

But I get error 500.

Console error:

  response: {
[vite:dev]     type: 'Link resolver error',
[vite:dev]     message: '[Link resolver error] Invalid resolver category\n' +
[vite:dev]       'It must be a content relationship linked to one and only one custom typ'
[vite:dev]   }
[vite:dev] }

I would really appreciate your help to help me understand this. I think the relationship is linked to only one type, so it is kinda confusing.

Thanks again!

Impacted feature

Link resolver

What steps have you taken to resolve this issue already?

Read docs. Modifying routes const

Errors

Invalid resolver category

Your Role

Freelancer developer

Hosting provider

local

1 Like

Figured this out. Thanks.

Within the docs, resolvers: {category: 'category'} makes it confusing.

resolvers: { dynamicpathname: 'relationship-API-id' } is how I finally understood.

1 Like