The Node.js® Website

chore: minor change on route

Changed files
+13 -6
app
[locale]
next-data
+13 -6
app/[locale]/next-data/og/route.tsx
··· 2 2 3 3 import HexagonGrid from '@/components/Icons/HexagonGrid'; 4 4 import JsIconWhite from '@/components/Icons/Logos/JsIconWhite'; 5 - import { ENABLE_STATIC_EXPORT, VERCEL_REVALIDATE } from '@/next.constants.mjs'; 5 + import { 6 + ENABLE_STATIC_EXPORT, 7 + VERCEL_ENV, 8 + VERCEL_REVALIDATE, 9 + } from '@/next.constants.mjs'; 6 10 import { defaultLocale } from '@/next.locales.mjs'; 7 11 import tailwindConfig from '@/tailwind.config'; 8 12 import { hexToRGBA } from '@/util/hexToRGBA'; 13 + 14 + // This is the default type of blog post type that we use for OG 15 + const defaultTypeParam = 'announcement'; 9 16 10 17 // This is the Route Handler for the `GET` method which handles the request 11 18 // for generating OpenGrapgh images for Blog Posts and Pages ··· 17 24 const hasTitle = searchParams.has('title'); 18 25 const title = hasTitle ? searchParams.get('title')?.slice(0, 100) : undefined; 19 26 20 - //?type=<type> - if undefined default to announcement 21 - const typeParam = searchParams.get('type') ?? 'announcement'; 27 + // ?type=<type> - if undefined default to announcement 28 + const typeParam = searchParams.get('type') ?? defaultTypeParam; 22 29 23 30 const typeAttributes: { [key: string]: string } = { 24 31 announcement: tailwindConfig.theme.colors.green['700'], ··· 27 34 }; 28 35 29 36 // use the mapped value, or if not found use announcement 30 - const type = 31 - typeAttributes[typeParam] ?? tailwindConfig.theme.colors.green['700']; 37 + const type = typeAttributes[typeParam] ?? typeAttributes[defaultTypeParam]; 32 38 33 39 const gridBackground = `radial-gradient(circle, ${hexToRGBA(type)}, transparent)`; 34 40 ··· 55 61 ]; 56 62 57 63 // We want to use `edge` runtime when using Vercel 58 - export const runtime = process.env.NEXT_PUBLIC_VERCEL_URL ? 'edge' : false; 64 + // @see https://nextjs.org/docs/app/api-reference/file-conventions/route-segment-config#runtime 65 + export const runtime = VERCEL_ENV ? 'edge' : 'nodejs'; 59 66 60 67 // Enforces that only the paths from `generateStaticParams` are allowed, giving 404 on the contrary 61 68 // @see https://nextjs.org/docs/app/api-reference/file-conventions/route-segment-config#dynamicparams