From 77e41e922bcc6fa33e8c0c5156f541c9e6bc2c70 Mon Sep 17 00:00:00 2001 From: khalilcodes Date: Mon, 13 Jun 2022 00:45:46 +0300 Subject: [PATCH] [site/mdx][s]: add logic for twitter embeds --- site/components/Paragraph.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/site/components/Paragraph.js b/site/components/Paragraph.js index 3940a5d..c3e985d 100644 --- a/site/components/Paragraph.js +++ b/site/components/Paragraph.js @@ -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 ; + if (YOUTUBE_REGEX.test(props.children.props.href)) { + const youtubeId = props.children.props.href.split(/^|=|\//).pop(); + return ; + } + + if (TWITTER_REGEX.test(props.children.props.href)) { + return ; + } } return

; };