Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions apps/site/next-data/blogData.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
import {
ENABLE_STATIC_EXPORT,
IS_DEV_ENV,
NEXT_DATA_URL,
VERCEL_ENV,
VERCEL_REGION,
IS_NOT_VERCEL_RUNTIME_ENV,
} from '@/next.constants.mjs';
import type { BlogCategory, BlogPostsRSC } from '@/types';

const getBlogData = (
cat: BlogCategory,
page?: number
): Promise<BlogPostsRSC> => {
const IS_NOT_VERCEL_RUNTIME_ENV =
(!IS_DEV_ENV && VERCEL_ENV && !VERCEL_REGION) ||
(!IS_DEV_ENV && !VERCEL_ENV);

// When we're using Static Exports the Next.js Server is not running (during build-time)
// hence the self-ingestion APIs will not be available. In this case we want to load
// the data directly within the current thread, which will anyways be loaded only once
Expand Down
8 changes: 1 addition & 7 deletions apps/site/next-data/downloadSnippets.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import {
ENABLE_STATIC_EXPORT,
IS_DEV_ENV,
NEXT_DATA_URL,
VERCEL_ENV,
VERCEL_REGION,
IS_NOT_VERCEL_RUNTIME_ENV,
} from '@/next.constants.mjs';
import { availableLocaleCodes } from '@/next.locales.mjs';
import type { DownloadSnippet } from '@/types';
Expand All @@ -17,10 +15,6 @@ export default async function getDownloadSnippets(
return [];
}

const IS_NOT_VERCEL_RUNTIME_ENV =
(!IS_DEV_ENV && VERCEL_ENV && !VERCEL_REGION) ||
(!IS_DEV_ENV && !VERCEL_ENV);

// When we're using Static Exports the Next.js Server is not running (during build-time)
// hence the self-ingestion APIs will not be available. In this case we want to load
// the data directly within the current thread, which will anyways be loaded only once
Expand Down
8 changes: 1 addition & 7 deletions apps/site/next-data/releaseData.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
import {
ENABLE_STATIC_EXPORT,
IS_DEV_ENV,
NEXT_DATA_URL,
VERCEL_ENV,
VERCEL_REGION,
IS_NOT_VERCEL_RUNTIME_ENV,
} from '@/next.constants.mjs';
import type { NodeRelease } from '@/types';

const getReleaseData = (): Promise<Array<NodeRelease>> => {
const IS_NOT_VERCEL_RUNTIME_ENV =
(!IS_DEV_ENV && VERCEL_ENV && !VERCEL_REGION) ||
(!IS_DEV_ENV && !VERCEL_ENV);

// When we're using Static Exports the Next.js Server is not running (during build-time)
// hence the self-ingestion APIs will not be available. In this case we want to load
// the data directly within the current thread, which will anyways be loaded only once
Expand Down
12 changes: 12 additions & 0 deletions apps/site/next.constants.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,18 @@ export const VERCEL_ENV = process.env.VERCEL_ENV || undefined;
*/
export const VERCEL_REGION = process.env.VERCEL_REGION || undefined;

/**
* This constant determines if the current environment is NOT a Vercel runtime environment.
*
* The logic is as follows:
* - If we are NOT in a development environment (`!IS_DEV_ENV`) AND:
* - Vercel environment variable (`VERCEL_ENV`) is defined but the Vercel region (`VERCEL_REGION`) is NOT defined, OR
* - Vercel environment variable (`VERCEL_ENV`) is NOT defined at all.
* This helps identify cases where the application is running outside of Vercel's runtime environment.
*/
export const IS_NOT_VERCEL_RUNTIME_ENV =
!IS_DEV_ENV && ((VERCEL_ENV && !VERCEL_REGION) || !VERCEL_ENV);

/**
* This is used for telling Next.js to do a Static Export Build of the Website
*
Expand Down
Loading