From 9ffb79ae1764368e863efcbd74f6e6c11f8c58b5 Mon Sep 17 00:00:00 2001 From: Pinapelz 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(-) 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 = ({ newsItems }) => { {/* Content */}

- {news.content} + {news.content.split(/(\[.*?\]\(.*?\)|https?:\/\/[^\s]+)/g).map((part, index) => { + const match = part.match(/\[(.*?)\]\((.*?)\)/); + const urlMatch = part.match(/https?:\/\/[^\s]+/); + if (match) { + return ( + + {match[1]} + + ); + } else if (urlMatch) { + return ( + + {urlMatch[0]} + + ); + } + return part; + })}

-- cgit v1.2.3