From b2fb358bb03a7bd34feb5d9531de17d4d4d83089 Mon Sep 17 00:00:00 2001 From: Taken Date: Sat, 27 Sep 2025 18:55:46 +0200 Subject: [PATCH] Updated types --- .../guild/[value]/_components/sidebar.tsx | 22 +------------------ .../player/[ign]/_components/social-icons.tsx | 3 ++- src/components/link-replace.tsx | 22 +++++++++++++++++++ 3 files changed, 25 insertions(+), 22 deletions(-) create mode 100644 src/components/link-replace.tsx diff --git a/src/app/(stats)/guild/[value]/_components/sidebar.tsx b/src/app/(stats)/guild/[value]/_components/sidebar.tsx index d92dbff..cce1fcc 100644 --- a/src/app/(stats)/guild/[value]/_components/sidebar.tsx +++ b/src/app/(stats)/guild/[value]/_components/sidebar.tsx @@ -1,9 +1,9 @@ +import { ReplaceLinks } from "@/components/link-replace" import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card" import { Separator } from "@/components/ui/separator" import { getColor } from "@/lib/colors" import { Guild } from "@/lib/schema/guild" import { cn } from "@/lib/utils" -import Link from "next/link" type SidebarProps = { guild: Guild["guild"] } @@ -26,23 +26,3 @@ export default function Sidebar({ guild }: SidebarProps) { ) } - -function ReplaceLinks({ text }: { text: string }) { - const regex = /(https?:\/\/[^\s/$.?#].[^\s]*)/g - const parts = text.split(regex) - - return ( -
- {parts.map((part, index) => { - if (regex.test(part)) { - return ( - - {part} - - ) - } - return part - })} -
- ) -} diff --git a/src/app/(stats)/player/[ign]/_components/social-icons.tsx b/src/app/(stats)/player/[ign]/_components/social-icons.tsx index c337042..3ebae95 100644 --- a/src/app/(stats)/player/[ign]/_components/social-icons.tsx +++ b/src/app/(stats)/player/[ign]/_components/social-icons.tsx @@ -1,4 +1,5 @@ import { Button } from "@/components/ui/button" +import { Route } from "next" import Link from "next/link" import { CgWebsite } from "react-icons/cg" import { FaTwitch, FaYoutube } from "react-icons/fa" @@ -38,7 +39,7 @@ function SocialIcon({ href, children }: { href?: string, children: React.ReactNo return ( diff --git a/src/components/link-replace.tsx b/src/components/link-replace.tsx new file mode 100644 index 0000000..511a1e4 --- /dev/null +++ b/src/components/link-replace.tsx @@ -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 ( +
+ {parts.map((part, i) => { + if (regex.test(part)) { + return ( + + {part} + + ) + } + return {part} + })} +
+ ) +}