We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b956465 commit 26f30c3Copy full SHA for 26f30c3
examples/nextjs/pages/index.tsx
@@ -1,5 +1,5 @@
1
import Head from 'next/head';
2
-import parse from 'html-react-parser';
+import parse, { Element } from 'html-react-parser';
3
4
export default function Home() {
5
return (
@@ -10,10 +10,23 @@ export default function Home() {
10
11
<main>
12
<h1 className="title">
13
- {parse(`
+ {parse(
14
+ `
15
Welcome to <a href="https://nextjs.org">Next.js</a>
16
and HTMLReactParser!
- `)}
17
+ `,
18
+ {
19
+ replace(domNode) {
20
+ if (domNode instanceof Element && domNode.name === 'a') {
21
+ return (
22
+ <a href="https://nextjs.org" rel="noopener noreferrer">
23
+ Next.js
24
+ </a>
25
+ );
26
+ }
27
+ },
28
29
+ )}
30
</h1>
31
</main>
32
0 commit comments