[site/mdx][s]: add logic for twitter embeds
This commit is contained in:
parent
007742af23
commit
77e41e922b
|
|
@ -1,15 +1,21 @@
|
|||
import LiteYouTubeEmbed from "react-lite-youtube-embed";
|
||||
import { YOUTUBE_REGEX } from "../lib/constants";
|
||||
import TwitterEmbed from "./TwitterEmbed";
|
||||
import { YOUTUBE_REGEX, TWITTER_REGEX } from "../lib/constants";
|
||||
|
||||
export const Paragraph = (props) => {
|
||||
if (
|
||||
typeof props.children == "object" &&
|
||||
props.children.props &&
|
||||
props.children.props.href &&
|
||||
YOUTUBE_REGEX.test(props.children.props.href)
|
||||
props.children.props.href
|
||||
) {
|
||||
const youtubeId = props.children.props.href.split(/^|=|\//).pop();
|
||||
return <LiteYouTubeEmbed id={youtubeId} />;
|
||||
if (YOUTUBE_REGEX.test(props.children.props.href)) {
|
||||
const youtubeId = props.children.props.href.split(/^|=|\//).pop();
|
||||
return <LiteYouTubeEmbed id={youtubeId} />;
|
||||
}
|
||||
|
||||
if (TWITTER_REGEX.test(props.children.props.href)) {
|
||||
return <TwitterEmbed url={props.children.props.href} {...props} />;
|
||||
}
|
||||
}
|
||||
return <p {...props} />;
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue