diff --git a/app/[locale]/og.jpg/blog/[...slug]/route.tsx b/app/[locale]/og.jpg/blog/[...slug]/route.tsx index 6ed31ca76..e8dad7921 100644 --- a/app/[locale]/og.jpg/blog/[...slug]/route.tsx +++ b/app/[locale]/og.jpg/blog/[...slug]/route.tsx @@ -1,3 +1,4 @@ +import { SKIP_OG_IMAGES } from 'lib/constants'; import { locales } from 'lib/i18n/config'; import { getAllContentSlugs, readAndParseContentFile } from 'lib/utils/markdown-content'; import { generateOgImage, loadDataUrl } from 'lib/utils/og'; @@ -13,8 +14,8 @@ interface Props { }; } -export const dynamic = 'error'; -export const dynamicParams = false; +export const dynamic = SKIP_OG_IMAGES ? 'error' : 'force-dynamic'; +export const dynamicParams = SKIP_OG_IMAGES; export const generateStaticParams = () => { const slugs = getAllContentSlugs('blog'); diff --git a/app/[locale]/og.jpg/blog/route.tsx b/app/[locale]/og.jpg/blog/route.tsx index 6b5668b4d..490b884b6 100644 --- a/app/[locale]/og.jpg/blog/route.tsx +++ b/app/[locale]/og.jpg/blog/route.tsx @@ -1,3 +1,4 @@ +import { SKIP_OG_IMAGES } from 'lib/constants'; import { locales } from 'lib/i18n/config'; import { generateOgImage, loadDataUrl } from 'lib/utils/og'; import { getTranslations } from 'next-intl/server'; @@ -11,8 +12,8 @@ interface Props { }; } -export const dynamic = 'error'; -export const dynamicParams = false; +export const dynamic = SKIP_OG_IMAGES ? 'error' : 'force-dynamic'; +export const dynamicParams = SKIP_OG_IMAGES; export const generateStaticParams = () => { return locales.map((locale) => ({ locale })); diff --git a/app/[locale]/og.jpg/exploits/route.tsx b/app/[locale]/og.jpg/exploits/route.tsx index 2f4335b7e..0a2dee5dc 100644 --- a/app/[locale]/og.jpg/exploits/route.tsx +++ b/app/[locale]/og.jpg/exploits/route.tsx @@ -1,3 +1,4 @@ +import { SKIP_OG_IMAGES } from 'lib/constants'; import { locales } from 'lib/i18n/config'; import { generateOgImage, loadDataUrl } from 'lib/utils/og'; import { getTranslations } from 'next-intl/server'; @@ -11,8 +12,8 @@ interface Props { }; } -export const dynamic = 'error'; -export const dynamicParams = false; +export const dynamic = SKIP_OG_IMAGES ? 'error' : 'force-dynamic'; +export const dynamicParams = SKIP_OG_IMAGES; export const generateStaticParams = () => { return locales.map((locale) => ({ locale })); diff --git a/app/[locale]/og.jpg/learn/[...slug]/route.tsx b/app/[locale]/og.jpg/learn/[...slug]/route.tsx index c1818894d..7552a64f6 100644 --- a/app/[locale]/og.jpg/learn/[...slug]/route.tsx +++ b/app/[locale]/og.jpg/learn/[...slug]/route.tsx @@ -1,3 +1,4 @@ +import { SKIP_OG_IMAGES } from 'lib/constants'; import { locales } from 'lib/i18n/config'; import { getAllContentSlugs, readAndParseContentFile } from 'lib/utils/markdown-content'; import { generateOgImage, loadDataUrl } from 'lib/utils/og'; @@ -13,8 +14,8 @@ interface Props { }; } -export const dynamic = 'error'; -export const dynamicParams = false; +export const dynamic = SKIP_OG_IMAGES ? 'error' : 'force-dynamic'; +export const dynamicParams = SKIP_OG_IMAGES; export const generateStaticParams = () => { const slugs = getAllContentSlugs('learn'); diff --git a/app/[locale]/og.jpg/learn/[category]/route.tsx b/app/[locale]/og.jpg/learn/[category]/route.tsx index a02accd6a..627d62980 100644 --- a/app/[locale]/og.jpg/learn/[category]/route.tsx +++ b/app/[locale]/og.jpg/learn/[category]/route.tsx @@ -1,3 +1,4 @@ +import { SKIP_OG_IMAGES } from 'lib/constants'; import { locales } from 'lib/i18n/config'; import { getAllLearnCategories } from 'lib/utils/markdown-content'; import { generateOgImage, loadDataUrl } from 'lib/utils/og'; @@ -13,8 +14,8 @@ interface Props { }; } -export const dynamic = 'error'; -export const dynamicParams = false; +export const dynamic = SKIP_OG_IMAGES ? 'error' : 'force-dynamic'; +export const dynamicParams = SKIP_OG_IMAGES; export const generateStaticParams = () => { const categorySlugs = getAllLearnCategories(); diff --git a/app/[locale]/og.jpg/learn/faq/route.tsx b/app/[locale]/og.jpg/learn/faq/route.tsx index 8d0d622da..ae7e8726e 100644 --- a/app/[locale]/og.jpg/learn/faq/route.tsx +++ b/app/[locale]/og.jpg/learn/faq/route.tsx @@ -11,7 +11,7 @@ interface Props { }; } -export const dynamic = 'error'; +export const dynamic = process.env.SKIP_OG_IMAGES === 'true' ? 'error' : 'force-dynamic'; export const dynamicParams = false; export const generateStaticParams = () => { diff --git a/app/[locale]/og.jpg/learn/route.tsx b/app/[locale]/og.jpg/learn/route.tsx index 00f5d5755..dff2ec5ea 100644 --- a/app/[locale]/og.jpg/learn/route.tsx +++ b/app/[locale]/og.jpg/learn/route.tsx @@ -1,3 +1,4 @@ +import { SKIP_OG_IMAGES } from 'lib/constants'; import { locales } from 'lib/i18n/config'; import { generateOgImage, loadDataUrl } from 'lib/utils/og'; import { getTranslations } from 'next-intl/server'; @@ -11,8 +12,8 @@ interface Props { }; } -export const dynamic = 'error'; -export const dynamicParams = false; +export const dynamic = SKIP_OG_IMAGES ? 'error' : 'force-dynamic'; +export const dynamicParams = SKIP_OG_IMAGES; export const generateStaticParams = () => { return locales.map((locale) => ({ locale })); diff --git a/app/[locale]/og.jpg/learn/wallets/add-network/[slug]/route.tsx b/app/[locale]/og.jpg/learn/wallets/add-network/[slug]/route.tsx index 2c2df1b02..51795fb7a 100644 --- a/app/[locale]/og.jpg/learn/wallets/add-network/[slug]/route.tsx +++ b/app/[locale]/og.jpg/learn/wallets/add-network/[slug]/route.tsx @@ -1,3 +1,4 @@ +import { SKIP_OG_IMAGES } from 'lib/constants'; import { locales } from 'lib/i18n/config'; import { SUPPORTED_CHAINS, getChainIdFromSlug, getChainName, getChainSlug } from 'lib/utils/chains'; import { generateOgImage, loadDataUrl } from 'lib/utils/og'; @@ -13,8 +14,8 @@ interface Props { }; } -export const dynamic = 'error'; -export const dynamicParams = false; +export const dynamic = SKIP_OG_IMAGES ? 'error' : 'force-dynamic'; +export const dynamicParams = SKIP_OG_IMAGES; export const generateStaticParams = () => { const slugs = SUPPORTED_CHAINS.map(getChainSlug); diff --git a/app/[locale]/og.jpg/learn/wallets/add-network/route.tsx b/app/[locale]/og.jpg/learn/wallets/add-network/route.tsx index 2f03ec165..efb7ab066 100644 --- a/app/[locale]/og.jpg/learn/wallets/add-network/route.tsx +++ b/app/[locale]/og.jpg/learn/wallets/add-network/route.tsx @@ -1,3 +1,4 @@ +import { SKIP_OG_IMAGES } from 'lib/constants'; import { locales } from 'lib/i18n/config'; import { generateOgImage, loadDataUrl } from 'lib/utils/og'; import { getTranslations } from 'next-intl/server'; @@ -11,8 +12,8 @@ interface Props { }; } -export const dynamic = 'error'; -export const dynamicParams = false; +export const dynamic = SKIP_OG_IMAGES ? 'error' : 'force-dynamic'; +export const dynamicParams = SKIP_OG_IMAGES; export const generateStaticParams = () => { return locales.map((locale) => ({ locale })); diff --git a/app/[locale]/og.jpg/token-approval-checker/[slug]/route.tsx b/app/[locale]/og.jpg/token-approval-checker/[slug]/route.tsx index f8ca07157..4b80829b6 100644 --- a/app/[locale]/og.jpg/token-approval-checker/[slug]/route.tsx +++ b/app/[locale]/og.jpg/token-approval-checker/[slug]/route.tsx @@ -1,3 +1,4 @@ +import { SKIP_OG_IMAGES } from 'lib/constants'; import { locales } from 'lib/i18n/config'; import { SUPPORTED_CHAINS, getChainIdFromSlug, getChainName, getChainSlug } from 'lib/utils/chains'; import { generateOgImage, loadDataUrl } from 'lib/utils/og'; @@ -13,8 +14,8 @@ interface Props { }; } -export const dynamic = 'error'; -export const dynamicParams = false; +export const dynamic = SKIP_OG_IMAGES ? 'error' : 'force-dynamic'; +export const dynamicParams = SKIP_OG_IMAGES; export const generateStaticParams = () => { const slugs = SUPPORTED_CHAINS.map(getChainSlug); diff --git a/lib/constants.ts b/lib/constants.ts index d8705f239..9395c7634 100644 --- a/lib/constants.ts +++ b/lib/constants.ts @@ -31,3 +31,5 @@ export const HARPIE_API_KEY = process.env.HARPIE_API_KEY ?? process.env.NEXT_PUB export const WEBACY_API_KEY = process.env.WEBACY_API_KEY ?? process.env.NEXT_PUBLIC_WEBACY_API_KEY; export const NEFTURE_API_KEY = process.env.NEFTURE_API_KEY ?? process.env.NEXT_PUBLIC_NEFTURE_API_KEY; export const RESERVOIR_API_KEY = process.env.RESERVOIR_API_KEY ?? process.env.NEXT_PUBLIC_RESERVOIR_API_KEY; + +export const SKIP_OG_IMAGES = process.env.SKIP_OG_IMAGES === 'true'; diff --git a/lib/utils/og.tsx b/lib/utils/og.tsx index 71b202b6b..66401c420 100644 --- a/lib/utils/og.tsx +++ b/lib/utils/og.tsx @@ -24,18 +24,6 @@ export const generateOgImage = ({ title, background }: OgImageProps) => { const width = 1200; const height = 630; - // If SKIP_OG_IMAGES is true, return a placeholder image instead of generating one dynamically. - // This significantly speeds up builds during emergency patches by skipping resource-intensive OG image generation. - const SKIP_OG_IMAGES = process.env.SKIP_OG_IMAGES === 'true'; - if (SKIP_OG_IMAGES) { - return new Response(loadFile('public/assets/images/opengraph-image.jpg'), { - headers: { - 'Content-Type': 'image/jpeg', - 'Cache-Control': 'public, max-age=31536000, immutable', - }, - }); - } - const icon = loadDataUrl('public/assets/images/revoke-icon-orange-black.svg', 'image/svg+xml'); const response = (