import { graphql } from "@/gql"; import { type EmbedBlockFragment } from "@/gql/graphql"; import styles from "./embedBlock.module.scss"; const EmbedBlockFragmentDefinition = graphql(` fragment EmbedBlock on EmbedBlock { url embed rawEmbed } `); export const EmbedBlock = ({ block }: { block: EmbedBlockFragment }) => { if (!block.embed) { return <>; } /* YouTube rawEmbed example { title: "EEEAAAOOO", type: "video", thumbnail_url: "https://i.ytimg.com/vi/v1K4EAXe2oo/hqdefault.jpg", width: 200, height: 113, html: '', }; */ let embedData: any = {}; try { embedData = block.rawEmbed ? JSON.parse(block.rawEmbed) : {}; } catch (e) { embedData = {}; } const { width, height } = embedData; const aspectRatio = width && height ? width / height : null; return (
); };