[Link resolver error]: It must be a content relationship linked to one and only one custom typ

Hello everyone. I'm trying to understand the link resolver of the client config. I'm getting the following error:

[Link resolver error] Invalid resolver page\n' +
      'It must be a content relationship linked to one and only one custom typ'

My project structure looks like this:
image

prismicio.ts

const routes: prismic.ClientConfig["routes"] = [
  {
    type: "homepage",
    path: "/",
  },
  {
    type: "page",
    path: "/:uid",
  },
  {
    type: "story",
    resolvers: {
      pageUid: "pageUid",
    },
    path: "/:pageUid/:uid",
  },
];

app/[lang]/[pageUid]/[storyUid]/page.tsx

export async function generateStaticParams() {
  const client = createClient();
  const stories = await client.getAllByType("story");
  const settings = await client.getAllByType("settings");

  return stories.map((story) => {
    const storiesDocument = settings.find((item) => item.lang === story.lang)
      ?.data?.stories_page;

    if (isFilled.contentRelationship(storiesDocument)) {
      return { pageUid: storiesDocument.uid, storyUid: story.uid };
    }
  });
}

What should my configuration look like for the story type? Where does the resolver get its values from? Why do I have to enter uid for the story uid and not storyUid?

Thank you very much for your help.

The path specified in your resolver configuration needs to match the file structure of your Next.js project. For example, if you're expecting a dynamic segment like :uid in your route, your file should be named [uid] > page.tsx for Next.js to recognize it properly.

I'm not sure what storyUid is in your use case, but it's possible that you might not need to do that content relationship field validation. You need to ensure that your resolver configuration matches the expected structure of your project. I recommend you take a look at the Route Resolver docs:

Also, it looks like we used outdated terminology in the error message. "Link Resolver" is now deprecated in favor of "Route Resolver". I'll add a feature request to update the naming of the errors.

Hey Pau,

Thank you for your help. I've read through this documentation multiple times and still feel uncertain. I understand it as you write: The path in the Link Resolver should reflect the project structure of NextJS. In my case, the path to a story should look like this:

{
  type: "story",
  path: "/:pageUid/:storyUid",
},

Project Structure
image

However, when I do that, I receive the following message:

Error: [Link resolver error] The following resolvers are missing for page type story:
- storyUid

The first dynamic route [lang] is added via middleware, which we can irgnore here.

Where does the Link Resolver get the variable values in the path from? Does it get these from the generateStaticParams function in page.tsx?