Setting up router resolver using slice machine on next.js

I'm getting this error when working through the advanced tutorial here: The Route Resolver - Prismic

Server Error

Error: The provided path / does not match the page: /[category]/[uid].

I only want to create a /:category/:uid/ path.

REPO:

Any help or direction you could provide is greatly appreciated it!

Hey Rowan,

I checked out your project and seems like it should work.

Are you still seeing the error? I'm testing further.

Thanks.

I guess it's coming from formatPaths in the [uid].js file not the route resolver, I'm investigating further.

Hey @rowan.flack,

I finally after all this time got a chance to see to this. Sorry for the long delay.

So when using the route resolver with Next.js you'll need to provide the data from the content relationship to the format paths option like so:

formatPath: ({ data, uid }) => ({ params: { category: data.category.uid || '', uid } }),

I'm going to update the documentation to include this extra information for anyone in the future. :slight_smile:

Although in your project is still returning an empty Slice Zone as you haven't added any Shared Slices in your repo or created a component for the Slice you created in Prismic or passed the data for that Slice through the SliceZone component.

Also, you're trying to parse the heading data in the Rich Text component but you haven't imported it yet using (Although the errors with your Slice Zone are causing this to break anyway):

import { RichText } from 'prismic-reactjs'

I would recommend starting from one of our Sample projects:

Thanks.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.