feat: Berrycast embed support

This commit is contained in:
Tom Moor
2022-03-30 17:09:19 -07:00
parent 7216551164
commit 7f3b602259
3 changed files with 36 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
import * as React from "react";
import useComponentSize from "~/hooks/useComponentSize";
import Frame from "../components/Frame";
import { EmbedProps as Props } from ".";
const URL_REGEX = /^https:\/\/(www\.)?berrycast.com\/conversations\/(.*)$/;
export default function Berrycast(props: Props) {
const normalizedUrl = props.attrs.href.replace(/\/$/, "");
const ref = React.useRef<HTMLDivElement>(null);
const { width } = useComponentSize(ref);
return (
<>
<div ref={ref} />
<Frame
{...props}
src={`${normalizedUrl}/video-player`}
title="Berrycast Embed"
height={`${0.5625 * width}px`}
border={false}
/>
</>
);
}
Berrycast.ENABLED = [URL_REGEX];