Updated types

This commit is contained in:
2025-09-27 18:55:46 +02:00
parent d13ef3bea9
commit b2fb358bb0
3 changed files with 25 additions and 22 deletions

View File

@@ -0,0 +1,22 @@
import { Route } from "next"
import Link from "next/link"
export function ReplaceLinks({ text }: { text: string }) {
const regex = /(https?:\/\/[^\s/$.?#].[^\s]*)/g
const parts = text.split(regex)
return (
<div>
{parts.map((part, i) => {
if (regex.test(part)) {
return (
<Link key={i} href={part as Route} target="_blank">
{part}
</Link>
)
}
return <span key={i}>{part}</span>
})}
</div>
)
}