We have a client that wants multi-level URLs (3 deep) on their website. To achieve this we created a SLUG field and updated the LinkResolver so that slugs work effectively.
However, when it comes to RichText fields there is a problem. The link data in those fields only ever returns...
If this is a case that you are receiving the correct data in the linkresolver, but not in the rich text fields then maybe the link resolver isn't being passed correctly in your htmlserializer. Can you check how your links are handled there?
Alternatively if your URL's go no deeper than:
/grandparent/parent/uid
You can create a Slice Machine/ Nuxt project and create nested routes that way.
Alas, I can't use slice machine on this project, as part of it already React Based.
The Link resolver works fine when using Link Resolver standalone on buttons components etc. Its when I come to use this on links inside RichText. I ONLY receive the _meta info back from prismic
I have the same issue
The element.data is not returning fields of the document I need to build the url
The slug is only the last part of the url which also depends on other data from the document;
ho wan I fetch data from the document within the rich text component?
Since we cannot put part of paths in the uid, we created a field called urlPrefix
We have a type blog-post with an urlPrefix that can take multiple values, and our urls are build with this syntax: locale/urlPrefix/uid
We need to be able to build the url with this custom urlPrefix field. The inability to do so:
creates SEO issues
forces us to add redirects
prevents us from leveraging static optimization (because dynamic of redirects)
forces us to do ugly things
An alternative would be to let us add slashes / in the uid field
But I guess other people might want to query other fields of linked documents for other reasons...
Are you building your project with Gatsby & GraphQL? because if that's the case you won't be able to access the document data to get the urlPrefix in the rich text field. It's just a limitation of these technologies. All though it would work in the link field if you pass the correct data to the link resolver.
Alternatively if you were using a technology like Next.js or Nuxt you can use the Route Resolver and build your URLs to the grand parent level. i.e. /grandparent/parent/uid
Having slashes in the UID won't be something that the team will be implementing unfortunately, but it is being tracked as a feature request.
we're already passing a custom linkResolver but the links to resolve are for documents that might be of any part of the site.
If so, how can I build the route if I cannot fetch this urlPrefix the route depends on? Or what is the logic of this grandparent/parent thing ? what if we link a document from a completely different section of the website? (not the current parent or grand parent)
basically, we need to access the document data beyond its meta and so far we don't see any solution
and this is because we are using the same type for multiple sections of our website, not doing so would force us to maintain identical types and complexify our app logic
There should be a solution depending on how links are being passed to the link resolver.
Can you show me where you're declaring the link resolver in your rich text fields or other places? Better yet if you can give me the github of your project I can test a solution.
Thanks.
Phil
(Phil Snow)
closed , flag & select 'Something Else' to reopen.
24
This issue has been closed due to inactivity. Flag to reopen.
I'm having the same issue as is described here. The thread doesn't come to a resolution. Only that you looked at the REPO. Was it unresolved?
I have pages 2 segments deep - '/page/page/' and having difficulty using the linkResolver. I can get the correct path from a relationship field but it's the richtext field that doesn't return the documents relationship field. Only the data that is described in the thread.
To quote from above thread
"Are you building your project with Gatsby & GraphQL? because if that's the case you won't be able to access the document data to get the urlPrefix in the rich text field. It's just a limitation of these technologies. All though it would work in the link field if you pass the correct data to the link resolver."
I am using a relationship field. How would I send this to the link resolver?
When I log what goes through the linkresolver.js I can see the problem. Here are the output for two different links.
Output hidden to public
See 2 result has data.section.uid which provides the slug to build the correct link /page/page/ but the first result doesn't have these fields? Do you know why?
Also the difference between the two fields above is the top output is a relationship field in a group field... We also get this output from a slice field that carries a rich-text field within it.