Add support for Twitter and Telegram

This commit is contained in:
Lachlan Kermode
2022-03-06 19:34:12 -05:00
parent b9eac1ce9a
commit 4113c04830
8 changed files with 142 additions and 13 deletions

View File

@@ -1,6 +1,8 @@
import React, { useRef } from "react";
import { useCallback } from "react";
import { typeForPath } from "../../../common/utilities";
import { TwitterTweetEmbed } from "react-twitter-embed";
import TelegramPostEmbed from "./TelegramEmbed";
const TITLE_LENGTH = 50;
// TODO should videos
@@ -53,6 +55,25 @@ const Media = ({ src, title }) => {
</div>
</div>
);
case "Telegram":
return (
<div className="card-cell media embedded">
<TelegramPostEmbed src={src} />
</div>
);
case "Tweet":
const tweetIdRegex =
/https?:\/\/twitter.com\/[0-9a-zA-Z_]{1,20}\/status\/([0-9]*)/;
const match = tweetIdRegex.exec(src);
const tweetId = match[1];
return (
<div className="card-cell media embedded">
<TwitterTweetEmbed tweetId={tweetId} />
</div>
);
default:
return null;
}