Updated types
This commit is contained in:
@@ -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) {
|
||||
</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>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -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 (
|
||||
<Button variant="ghost" className="transition-all hover:scale-125" asChild>
|
||||
<Link href={`https://${href.replace("https://", "")}`}>
|
||||
<Link href={href as Route}>
|
||||
{children}
|
||||
</Link>
|
||||
</Button>
|
||||
|
||||
22
src/components/link-replace.tsx
Normal file
22
src/components/link-replace.tsx
Normal 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>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user