From 26f30c3bf7f195241e7ac3bb8637b4c114fa0cf5 Mon Sep 17 00:00:00 2001 From: Mark Date: Fri, 1 Nov 2024 12:40:01 -0400 Subject: [PATCH] chore(examples): add replace to nextjs https://github.com/remarkablemark/html-react-parser/issues/1589 --- examples/nextjs/pages/index.tsx | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/examples/nextjs/pages/index.tsx b/examples/nextjs/pages/index.tsx index 7b69a22f..1a51fd89 100644 --- a/examples/nextjs/pages/index.tsx +++ b/examples/nextjs/pages/index.tsx @@ -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 ( @@ -10,10 +10,23 @@ export default function Home() {

- {parse(` + {parse( + ` Welcome to Next.js and HTMLReactParser! - `)} + `, + { + replace(domNode) { + if (domNode instanceof Element && domNode.name === 'a') { + return ( + + Next.js + + ); + } + }, + }, + )}