Skip to content

Commit

Permalink
chore(examples): add replace to nextjs
Browse files Browse the repository at this point in the history
  • Loading branch information
remarkablemark committed Nov 1, 2024
1 parent b956465 commit 26f30c3
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions examples/nextjs/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Head from 'next/head';
import parse from 'html-react-parser';
import parse, { Element } from 'html-react-parser';

export default function Home() {
return (
Expand All @@ -10,10 +10,23 @@ export default function Home() {

<main>
<h1 className="title">
{parse(`
{parse(
`
Welcome to <a href="https://nextjs.org">Next.js</a>
and HTMLReactParser!
`)}
`,
{
replace(domNode) {
if (domNode instanceof Element && domNode.name === 'a') {
return (
<a href="https://nextjs.org" rel="noopener noreferrer">
Next.js
</a>
);
}
},
},
)}
</h1>
</main>

Expand Down

0 comments on commit 26f30c3

Please sign in to comment.