feat: render markdown
This commit is contained in:
parent
29f92b7cb2
commit
33e233d4a3
@ -12,7 +12,6 @@ import './Text.css'
|
||||
import { useMemo } from "react";
|
||||
|
||||
function transformHttpLink(a) {
|
||||
try {
|
||||
const url = new URL(a);
|
||||
const youtubeId = YoutubeUrlRegex.test(a) && RegExp.$1;
|
||||
const tweetId = TweetUrlRegex.test(a) && RegExp.$2;
|
||||
@ -39,7 +38,7 @@ function transformHttpLink(a) {
|
||||
}
|
||||
} else if (tweetId) {
|
||||
return (
|
||||
<div className="tweet" key={tweetId}>
|
||||
<div className="tweet">
|
||||
<TwitterTweetEmbed tweetId={tweetId} />
|
||||
</div>
|
||||
)
|
||||
@ -51,7 +50,6 @@ function transformHttpLink(a) {
|
||||
className="w-max"
|
||||
src={`https://www.youtube.com/embed/${youtubeId}`}
|
||||
title="YouTube video player"
|
||||
key={youtubeId}
|
||||
frameBorder="0"
|
||||
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
|
||||
allowFullScreen=""
|
||||
@ -62,8 +60,6 @@ function transformHttpLink(a) {
|
||||
} else {
|
||||
return <a href={a} onClick={(e) => e.stopPropagation()}>{a}</a>
|
||||
}
|
||||
} catch (error) {
|
||||
}
|
||||
return <a href={a} onClick={(e) => e.stopPropagation()}>{a}</a>
|
||||
}
|
||||
|
||||
@ -81,7 +77,7 @@ function extractLinks(fragments) {
|
||||
}).flat();
|
||||
}
|
||||
|
||||
export function extractMentions(fragments, tags, users) {
|
||||
function extractMentions(fragments, tags, users) {
|
||||
return fragments.map(f => {
|
||||
if (typeof f === "string") {
|
||||
return f.split(MentionRegex).map((match) => {
|
||||
@ -172,4 +168,3 @@ export default function Text({ content, tags, users }) {
|
||||
}, [content]);
|
||||
return <ReactMarkdown className="text" components={components}>{content}</ReactMarkdown>
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user