Custom Link when not using rich text

Hi,

I understand the concept of creating a CustomLink component for help when using richtext fields to make sure the user can link to the web or an internal page and then make sure it is using a Gatsby Link component.

But if I have a link type on a model which I'm fetching and want to do something similar do I have to do that manually using conditional rendering? Or is there a way to tweak the CustomLink component. What is recommended?

{slice.primary.link_url_left.link_type === "Web" && (
          <a href={slice.primary.link_url_left.url}>
            {RichText.asText(slice.primary.link_text_left.raw)}
          </a>
        )}
        {slice.primary.link_url_left.link_type === "Media" && (
          <a href={slice.primary.link_url_left.url} target="_blank">
            {RichText.asText(slice.primary.link_text_left.raw)}
          </a>
        )}
        {slice.primary.link_url_left.link_type === "Document" && (
          <Link to={slice.primary.link_url_left.url}>
            {RichText.asText(slice.primary.link_text_left.raw)}
          </Link>
        )}

Hey @ExposurePhil, thanks for reaching out!

The code snippet that you shared should cover all the link types inside Prismic documents. What is this other link type on a model that you're mentioning?

This thread has been closed due to inactivity. Flag to reopen.