Reputation: 314
I am developing Next.js app using Wordpress as headless CMS + GraphQL. Everything is clear except for internal content links in articles which I get via WP API. Such links are plain <a></a>
and trigger browser reloading. Is there any solution to replace them with Link Component
?
Upvotes: 0
Views: 466
Reputation: 767
I think you content should include in your Next.js app, then on content's parent element, you can bind a onClick
handler to capture click on links and use router.push
to simulate <Link>
behaviours like:
<div onClick={e => {
e.preventDefault();
if (e.target.href) router.push(e.target.href);
}}>
internal content with links
</div>
Upvotes: 2