Dynamic nested routes

Hello,

Thanks for reaching out us.

First, you don't need i18 for language implementation. you can add as many languages/locales as you need in Prismic and can query by language option. You can see our Multi-language example project.

Second, you should use the linkresolver. You will find complete detail here.

And we have discussed and fetchlinks here:

Here is the combination of lang and type to build links:

export default function (doc) {
  if (doc.isBroken) {
    return '/not-found';
  }

  if (doc.type === 'home') {
    return '/';
  }

  if (doc.type === 'page' && doc.lang ==== 'en-us') {
    return `/help/${doc.data.relationlink.data.name}/${doc.uid}`;
  }

  if (doc.type === 'page' && doc.lang ==== 'es-es') {
    return `/ayuda/${doc.data.relationlink.data.name}/${doc.uid}`;
  }

  return '/not-found';
};

And you can use route-resolver to build the complex paths:

I hope it answers your question. Let me know if you have other doubt.

Thanks,
Priyanka

1 Like