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

@@ -1,9 +1,9 @@
import { ReplaceLinks } from "@/components/link-replace"
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card" import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"
import { Separator } from "@/components/ui/separator" import { Separator } from "@/components/ui/separator"
import { getColor } from "@/lib/colors" import { getColor } from "@/lib/colors"
import { Guild } from "@/lib/schema/guild" import { Guild } from "@/lib/schema/guild"
import { cn } from "@/lib/utils" import { cn } from "@/lib/utils"
import Link from "next/link"
type SidebarProps = { guild: Guild["guild"] } type SidebarProps = { guild: Guild["guild"] }
@@ -26,23 +26,3 @@ export default function Sidebar({ guild }: SidebarProps) {
</Card> </Card>
) )
} }
function ReplaceLinks({ text }: { text: string }) {
const regex = /(https?:\/\/[^\s/$.?#].[^\s]*)/g
const parts = text.split(regex)
return (
<div>
{parts.map((part, index) => {
if (regex.test(part)) {
return (
<Link key={index} href={part} target="_blank">
{part}
</Link>
)
}
return part
})}
</div>
)
}

View File

@@ -1,4 +1,5 @@
import { Button } from "@/components/ui/button" import { Button } from "@/components/ui/button"
import { Route } from "next"
import Link from "next/link" import Link from "next/link"
import { CgWebsite } from "react-icons/cg" import { CgWebsite } from "react-icons/cg"
import { FaTwitch, FaYoutube } from "react-icons/fa" import { FaTwitch, FaYoutube } from "react-icons/fa"
@@ -38,7 +39,7 @@ function SocialIcon({ href, children }: { href?: string, children: React.ReactNo
return ( return (
<Button variant="ghost" className="transition-all hover:scale-125" asChild> <Button variant="ghost" className="transition-all hover:scale-125" asChild>
<Link href={`https://${href.replace("https://", "")}`}> <Link href={href as Route}>
{children} {children}
</Link> </Link>
</Button> </Button>

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>
)
}