import Document, { DocumentContext, Head, Html, Main, NextScript, DocumentProps } from "next/document"; type Props = Record & DocumentProps; class MyDocument extends Document { static async getInitialProps(ctx: DocumentContext) { const initialProps = await Document.getInitialProps(ctx); const isEmbed = ctx.req?.url?.includes("embed"); return { ...initialProps, isEmbed }; } render() { const props = this.props; const { locale } = this.props.__NEXT_DATA__; const dir = locale === "ar" || locale === "he" ? "rtl" : "ltr"; return ( {/* Keep the embed hidden till parent initializes and gives it the appropriate styles */}
); } } export default MyDocument;