File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed
Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -9,16 +9,26 @@ const BlogContent: React.FC<BlogContentProps> = ({ content }) => {
99 // Transform markdown-like content to JSX
1010 const createMarkup = ( ) => {
1111 let html = content
12+ // Bold text formatting
13+ . replace ( / \* \* ( .* ?) \* \* / g, '<strong class="font-bold">$1</strong>' )
14+
15+ // Links
16+ . replace ( / \[ ( [ ^ \] ] + ) \] \( ( [ ^ ) ] + ) \) / g, '<a href="$2" class="text-primary hover:underline" target="_blank" rel="noopener noreferrer">$1</a>' )
17+
1218 // Headers
1319 . replace ( / ^ # ( .* $ ) / gm, '<h1 class="blog-heading">$1</h1>' )
1420 . replace ( / ^ # # ( .* $ ) / gm, '<h2 class="blog-subheading">$1</h2>' )
1521 . replace ( / ^ # # # ( .* $ ) / gm, '<h3 class="text-xl font-semibold mb-3">$1</h3>' )
22+
1623 // Paragraphs
17- . replace ( / ^ (? ! < h [ 1 - 6 ] | < u l | < o l | < l i | < b l o c k q u o t e | < p r e ) ( .+ $ ) / gm, '<p class="blog-text">$1</p>' )
24+ . replace ( / ^ (? ! < h [ 1 - 6 ] | < u l | < o l | < l i | < b l o c k q u o t e | < p r e | < s t r o n g ) ( .+ $ ) / gm, '<p class="blog-text">$1</p>' )
25+
1826 // Lists
1927 . replace ( / ^ - ( .* ) $ / gm, '<li class="ml-6 list-disc">$1</li>' )
28+
2029 // Line breaks
2130 . replace ( / \n \n / g, '<br />' )
31+
2232 // Convert list items into proper lists
2333 . replace ( / < l i c l a s s = " m l - 6 l i s t - d i s c " > ( .* ?) < \/ l i > (?: \n < l i c l a s s = " m l - 6 l i s t - d i s c " > ( .* ?) < \/ l i > ) + / gs,
2434 match => `<ul class="mb-6">${ match } </ul>` ) ;
You can’t perform that action at this time.
0 commit comments