Skip to content

Connect, collaborate, and grow with a community of TypeScript developers

fix: add bluesky icon support and fix regex in magic-icon (#1727) (#1767)

Harshb8fa799cf085
diff --git a/packages/ui/src/components/magic-icon.tsx b/packages/ui/src/components/magic-icon.tsx
index d57e2e25..8f9eaa10 100644
--- a/packages/ui/src/components/magic-icon.tsx
+++ b/packages/ui/src/components/magic-icon.tsx
@@ -1,19 +1,23 @@
-// TODO: Handle the deprecation
-// > `Github` is deprecated. Brand icons have been deprecated and are due to be removed, please refer to https://github.com/lucide-icons/lucide/issues/670.
-// > We recommend using https://simpleicons.org/?q=github instead.
-// > This icon will be removed in v1.0
-/* eslint-disable @typescript-eslint/no-deprecated */
-import { Github, Link as LinkIcon, Linkedin, Twitter, Youtube } from 'lucide-react';
+import { Link as LinkIcon } from 'lucide-react';
+import {
+ SiBluesky,
+ SiGithub as Github,
+ SiX as Twitter,
+ SiYoutube as Youtube,
+ SiLinkedin as Linkedin,
+} from '@icons-pack/react-simple-icons';
import { cn } from '../cn';
export function MagicIcon({ url, className }: { url: string; className?: string }) {
- const githubRegex = /^(?:https?:\/\/)?(?:www\.)?github\.com\/(?:\w+)(\/)?$/;
- const twitterRegex = /^(?:https?:\/\/)?(?:www\.)?twitter\.com\/(?:\w+)(\/)?$/;
- const linkedinRegex = /^(?:https?:\/\/)?(?:www\.)?linkedin\.com\/(?:\w+)(\/)?$/;
- const youtubeRegex = /^(?:https?:\/\/)?(?:www\.)?youtube\.com\/(?:\w+)(\/)?$/;
-
+ const githubRegex = /^(?:https?:\/\/)?(?:www\.)?github\.com\/([\w-]+)(\/)?$/;
+ const twitterRegex = /^(?:https?:\/\/)?(?:www\.)?(?:twitter|x)\.com\/([\w-]+)(\/)?$/;
+ const linkedinRegex = /^(?:https?:\/\/)?(?:www\.)?linkedin\.com\/in\/([\w-]+)(\/)?$/;
+ const youtubeRegex =
+ /^(?:https?:\/\/)?(?:www\.)?youtube\.com\/(?:@[\w-]+|channel\/[\w-]+|c\/[\w-]+)(\/)?$/;
+ const blueskyRegex = /^(?:https?:\/\/)?(?:www\.)?bsky\.app\/profile\/([\w.-]+)(\/)?$/;
const lowercaseUrl = url.toLowerCase();
+ if (blueskyRegex.test(lowercaseUrl)) return <SiBluesky className={cn('h-3 w-3', className)} />;
if (githubRegex.test(lowercaseUrl)) return <Github className={cn('h-3 w-3', className)} />;
if (twitterRegex.test(lowercaseUrl)) return <Twitter className={cn('h-3 w-3', className)} />;
if (linkedinRegex.test(lowercaseUrl)) return <Linkedin className={cn('h-3 w-3', className)} />;