From 9ffb79ae1764368e863efcbd74f6e6c11f8c58b5 Mon Sep 17 00:00:00 2001
From: Pinapelz <yukais@pinapelz.com>
Date: Mon, 14 Apr 2025 16:34:29 -0700
Subject: frontend: add regex replacement for markdown inline links and regular
 urls

makes them clickable
---
 site/src/components/NewsFeed.tsx | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

(limited to 'site/src/components/NewsFeed.tsx')

diff --git a/site/src/components/NewsFeed.tsx b/site/src/components/NewsFeed.tsx
index 311fe75..a9b36cf 100644
--- a/site/src/components/NewsFeed.tsx
+++ b/site/src/components/NewsFeed.tsx
@@ -71,7 +71,24 @@ export const NewsFeed: React.FC<NewsFeedProps> = ({ newsItems }) => {
 
               {/* Content */}
               <p className="text-sm text-gray-200 whitespace-pre-line mb-2">
-                {news.content}
+                {news.content.split(/(\[.*?\]\(.*?\)|https?:\/\/[^\s]+)/g).map((part, index) => {
+                  const match = part.match(/\[(.*?)\]\((.*?)\)/);
+                  const urlMatch = part.match(/https?:\/\/[^\s]+/);
+                  if (match) {
+                    return (
+                      <a key={index} href={match[2]} target="_blank" rel="noopener noreferrer" className="text-blue-400 hover:underline">
+                        {match[1]}
+                      </a>
+                    );
+                  } else if (urlMatch) {
+                    return (
+                      <a key={index} href={urlMatch[0]} target="_blank" rel="noopener noreferrer" className="text-blue-400 hover:underline">
+                        {urlMatch[0]}
+                      </a>
+                    );
+                  }
+                  return part;
+                })}
               </p>
             </div>
 
-- 
cgit v1.2.3

