Add instagram embed (#6075)

This commit is contained in:
Prikshit Singh
2023-10-27 06:04:25 +05:30
committed by GitHub
parent afb5ccbf74
commit d6fcf44bf4
4 changed files with 48 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
import Instagram from "./Instagram";
describe("Instagram", () => {
const match = Instagram.ENABLED[0];
test("to be enabled on post link", () => {
expect(
"https://www.instagram.com/p/CrL74G6Bxgw/?utm_source=ig_web_copy_link".match(
match
)
).toBeTruthy();
});
test("to be enabled on reel link", () => {
expect(
"https://www.instagram.com/reel/Cxdyt_fMnwN/?utm_source=ig_web_copy_link".match(
match
)
).toBeTruthy();
});
test("to not be enabled elsewhere", () => {
expect("https://www.instagram.com".match(match)).toBe(null);
expect("https://www.instagram.com/reel/".match(match)).toBe(null);
expect("https://www.instagram.com/p/".match(match)).toBe(null);
});
});

View File

@@ -0,0 +1,14 @@
import * as React from "react";
import Frame from "../components/Frame";
import { EmbedProps as Props } from ".";
function Instagram(props: Props) {
const { matches } = props.attrs;
return <Frame {...props} src={`${matches[0]}/embed`} title="Instagram" />;
}
Instagram.ENABLED = [
/^https?:\/\/www\.instagram\.com\/(p|reel)\/([\w-]+)(\/?utm_source=\w+)?/,
];
export default Instagram;

View File

@@ -32,6 +32,7 @@ import GoogleSheets from "./GoogleSheets";
import GoogleSlides from "./GoogleSlides";
import Grist from "./Grist";
import InVision from "./InVision";
import Instagram from "./Instagram";
import JSFiddle from "./JSFiddle";
import Linkedin from "./Linkedin";
import Loom from "./Loom";
@@ -285,6 +286,12 @@ const embeds: EmbedDescriptor[] = [
icon: <Img src="/images/grist.png" alt="Grist" />,
component: Grist,
}),
new EmbedDescriptor({
title: "Instagram",
keywords: "post",
icon: <Img src="/images/instagram.png" alt="Instagram" />,
component: Instagram,
}),
new EmbedDescriptor({
title: "InVision",
keywords: "design prototype",