RichText renders the a tag but not the href for the dcument

Hi there

I have an issue where RichText isn't rendering a tags for links to documents. I've checked the JSON coming in and the links are there in the array.

I've tested with external web links and it works fine but when I try to link to another Document or Prismic Page the link just gives an empty href tag ie: <a href="">Title</a>

I have a link resolver in place for the different page types but still no hrefs being generated.

Any thoughts?

Hello Rob,

Welcome to the Prismic community.

Whenever you make changes in the Prismic documents, you need to save and published the document. And linked to internal documents always require a link resolver.
Please send me the followings:

  1. Prismic repo URL.
  2. Paste your link resolver function here.
  3. Paste your render method of the Rich text field. How are you outputting the text using asText or 'asHTML'? You need to use asHTML.
    Please follow this document for the Rich text field rendering.

I am looking forward to hearing from you back.

Thanks,
Priyanka

Hello, rob,

I am not sure what is wrong here. Everything looks good to me. I need to debug the code. Can you please share Github repo URL with me? You can send me a private message.

Thanks,
Priyanka

Hello @rob1

I have checked your project source code. And In the /src/components/accordian.js file, you are not importing the link resolver function from the prismic-configuration.js file. You have to import it from this file, not from the 'prismic-reactjs' library.

Thanks,
Priyanka

Perfect that works thank you!

Rob Brough
Founder / CTO
And Now Limited

+64 27 659 4075
rob@andnow.co.nz

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