prismic-react icon indicating copy to clipboard operation
prismic-react copied to clipboard

feat: globally configure the internal link component

Open angeloashmore opened this issue 4 weeks ago • 0 comments

Resolves: N/A

Description

[!IMPORTANT] This is an internal change. Do not use this feature directly in your website.

This PR allows for globally configuring the internal link component rendered by <PrismicLink> and <PrismicRichText>.

The default behavior does not change when using @prismicio/react directly; links will continue to render <a> by default.

This feature is intended for external packages to set default internal links. For example, @prismicio/next can set the default internal link to next/link.

Checklist

  • [ ] A comprehensive Linear ticket, providing sufficient context and details to facilitate the review of the PR, is linked to the PR.
  • [ ] If my changes require tests, I added them.
  • [ ] If my changes affect backward compatibility, it has been discussed.
  • [ ] If my changes require an update to the CONTRIBUTING.md guide, I updated it.

Preview

Somewhere in a module:

// The "@prismicio/react/config" key is important
globalThis[Symbol.for("@prismicio/react/config")] = {
	internalLinkComponent: (props) => (
		<a data-foo {...props} />
	),
};

The following components will now render internal links as <a data-foo {...props} />:

<PrismicLink field={...} />
<PrismicRichText field={...} />

How to QA [^1]

[^1]: Please use these labels when submitting a review: :question: #ask: Ask a question. :bulb: #idea: Suggest an idea. :warning: #issue: Strongly suggest a change. :tada: #nice: Share a compliment.

angeloashmore avatar Dec 13 '25 02:12 angeloashmore