Add LinkedIn embed (#5933)
Co-authored-by: Prikshit singh <prikshit.singh@aimedlabs.com>
This commit is contained in:
BIN
public/images/linkedin.png
Normal file
BIN
public/images/linkedin.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.5 KiB |
39
shared/editor/embeds/Linkedin.test.ts
Normal file
39
shared/editor/embeds/Linkedin.test.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
import Linkedin from "./Linkedin";
|
||||
|
||||
describe("Linkedin", () => {
|
||||
const match = Linkedin.ENABLED[0];
|
||||
|
||||
test("to be enabled on post link", () => {
|
||||
expect(
|
||||
"https://www.linkedin.com/posts/github_highlight-your-expertise-with-github-certifications-activity-7117157514097352704-F4Mz?utm_source=share&utm_medium=member_desktop".match(
|
||||
match
|
||||
)
|
||||
).toBeTruthy();
|
||||
});
|
||||
|
||||
test("to be enabled on embed link", () => {
|
||||
expect(
|
||||
"https://www.linkedin.com/embed/feed/update/urn:li:share:7117157513422090241".match(
|
||||
match
|
||||
)
|
||||
).toBeTruthy();
|
||||
});
|
||||
|
||||
test("to not be enabled elsewhere", () => {
|
||||
expect("https://www.linkedin.com/".match(match)).toBe(null);
|
||||
expect("https://www.linkedin.com/posts/".match(match)).toBe(null);
|
||||
expect("https://www.linkedin.com/embed/".match(match)).toBe(null);
|
||||
expect("https://www.linkedin.com/embed/feed/update/".match(match)).toBe(
|
||||
null
|
||||
);
|
||||
expect(
|
||||
"https://www.linkedin.com/embed/feed/update/urn:li:".match(match)
|
||||
).toBe(null);
|
||||
expect(
|
||||
"https://www.linkedin.com/embed/feed/update/urn:li:share:".match(match)
|
||||
).toBe(null);
|
||||
expect(
|
||||
"https://www.linkedin.com/embed/feed/update/urn:li:ugcPost:".match(match)
|
||||
).toBe(null);
|
||||
});
|
||||
});
|
||||
25
shared/editor/embeds/Linkedin.tsx
Normal file
25
shared/editor/embeds/Linkedin.tsx
Normal file
@@ -0,0 +1,25 @@
|
||||
import * as React from "react";
|
||||
import Frame from "../components/Frame";
|
||||
import { EmbedProps as Props } from ".";
|
||||
|
||||
function Linkedin(props: Props) {
|
||||
const { matches } = props.attrs;
|
||||
const objectId = matches[2];
|
||||
const postType = matches[1];
|
||||
if (matches[3] === "embed") {
|
||||
return <Frame {...props} src={`${props.attrs.href}`} title="LinkedIn" />;
|
||||
}
|
||||
return (
|
||||
<Frame
|
||||
{...props}
|
||||
src={`https://www.linkedin.com/embed/feed/update/urn:li:${postType}:${objectId}`}
|
||||
title="LinkedIn"
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
Linkedin.ENABLED = [
|
||||
/^https:\/\/www\.linkedin\.com\/(?:posts\/.*-(ugcPost|activity)-(\d+)-.*|(embed)\/(?:feed\/update\/urn:li:(?:ugcPost|share):(?:\d+)))/,
|
||||
];
|
||||
|
||||
export default Linkedin;
|
||||
@@ -33,6 +33,7 @@ import GoogleSlides from "./GoogleSlides";
|
||||
import Grist from "./Grist";
|
||||
import InVision from "./InVision";
|
||||
import JSFiddle from "./JSFiddle";
|
||||
import Linkedin from "./Linkedin";
|
||||
import Loom from "./Loom";
|
||||
import Lucidchart from "./Lucidchart";
|
||||
import Marvel from "./Marvel";
|
||||
@@ -298,6 +299,13 @@ const embeds: EmbedDescriptor[] = [
|
||||
icon: <Img src="/images/jsfiddle.png" alt="JSFiddle" />,
|
||||
component: JSFiddle,
|
||||
}),
|
||||
new EmbedDescriptor({
|
||||
title: "LinkedIn",
|
||||
keywords: "post",
|
||||
defaultHidden: true,
|
||||
icon: <Img src="/images/linkedin.png" alt="LinkedIn" />,
|
||||
component: Linkedin,
|
||||
}),
|
||||
new EmbedDescriptor({
|
||||
title: "Loom",
|
||||
keywords: "video screencast",
|
||||
|
||||
Reference in New Issue
Block a user