Skip to content

Commit

Permalink
fix: test
Browse files Browse the repository at this point in the history
  • Loading branch information
rkalis committed Dec 16, 2024
1 parent 9390685 commit a9a01cc
Show file tree
Hide file tree
Showing 12 changed files with 30 additions and 31 deletions.
5 changes: 3 additions & 2 deletions app/[locale]/og.jpg/blog/[...slug]/route.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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');
Expand Down
5 changes: 3 additions & 2 deletions app/[locale]/og.jpg/blog/route.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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 }));
Expand Down
5 changes: 3 additions & 2 deletions app/[locale]/og.jpg/exploits/route.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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 }));
Expand Down
5 changes: 3 additions & 2 deletions app/[locale]/og.jpg/learn/[...slug]/route.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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');
Expand Down
5 changes: 3 additions & 2 deletions app/[locale]/og.jpg/learn/[category]/route.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion app/[locale]/og.jpg/learn/faq/route.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 = () => {
Expand Down
5 changes: 3 additions & 2 deletions app/[locale]/og.jpg/learn/route.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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 }));
Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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);
Expand Down
5 changes: 3 additions & 2 deletions app/[locale]/og.jpg/learn/wallets/add-network/route.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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 }));
Expand Down
5 changes: 3 additions & 2 deletions app/[locale]/og.jpg/token-approval-checker/[slug]/route.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
12 changes: 0 additions & 12 deletions lib/utils/og.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 = (
Expand Down

0 comments on commit a9a01cc

Please sign in to comment.