Currently trying to set up a page for my new gatsby site that'll resolve to the index page. The uid for the slug can't be empty, has anyone fixed a way of doing this?
I've tried /index but sadly, that needs to be typed in to get the right page.
@Phil I have a computed function that maps page IDs to the slug key text. It’s very hacky and will be sub-optimal for large projects, but it works for me at the moment.
function linkResolver (doc) {
return parent.pageLinks[doc.id]
}
@marcellothearcane I haven’t played around with this feature a whole lot, but it seems like you could use the extraPageFields option as shown here to add categories to the url.
@marcellothearcane Your use case in Gridsome is more for parent categories in the link resolver.
You’ve got a few choices.
You could use the key text field to create completely arbitrary url paths, though this really isn’t recommended as there’s no validation on the Prismic side.
You can add a content relationship to the document and link to the parent and in your link resolver get the UID of the parent through this. You’ll need to use Fetch Links or GraphQuery(Fetchlinks V2) in the REST API, but it GraphQL you should be able to just grab this info directly.
We’ve worked a new Link Resolver that’s currently in BETA with Slice Machine which makes this process easier, you can test this by spinning up a Slice Machine repo and building your project from there. There’s some documentation for this here. Hopefully eventually in the future we’ll get this rolled out for everyone.
@hi11, yeah you can use an HTML Serializer to change the output of your Rich Text field. And you can provide a function that returns a function in order to pass data into the HTML Serializer. I give an example of this here: