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
7 changes: 3 additions & 4 deletions next.config.static.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ const withMDX = createMDX();
const isGitHubPagesBuild =
process.env.GITHUB_ACTIONS === 'true' || process.env.GITHUB_PAGES === 'true';
const isVercelBuild = process.env.VERCEL === '1';
const isVercelProd =
isVercelBuild && !['development', 'staging'].includes(process.env.VERCEL_ENV ?? '');
const isVercelProd = isVercelBuild && resolveBaseUrl().startsWith('https://docs.ton.org');
const isLocalBuild = !isGitHubPagesBuild && !isVercelBuild;
let gitRepoMatch: RegExpMatchArray | null = null;
try {
Expand All @@ -21,7 +20,7 @@ try {
gitRepoMatch = gitUrl.match(/(?:github\.com[:/])(.+?)\/(.+?)(?:\.git)?$/);
} catch {}

const resolveBaseUrl = () => {
function resolveBaseUrl() {
const publicUrl = process.env.NEXT_PUBLIC_SITE_URL;
if (publicUrl !== undefined && publicUrl !== '') {
return publicUrl;
Expand All @@ -34,7 +33,7 @@ const resolveBaseUrl = () => {
return 'http://localhost:3000';
};

const resolveBasePath = () => {
function resolveBasePath() {
if (isGitHubPagesBuild) {
return `/${gitConfig.repo}`;
}
Expand Down
12 changes: 6 additions & 6 deletions next.config.vercel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import type { Redirect } from 'next/dist/lib/load-custom-routes';
import { createMDX } from 'fumadocs-mdx/next';

const withMDX = createMDX();
const isVercelProd = !['development', 'staging'].includes(process.env.VERCEL_ENV ?? '');
const isVercelProd = resolveBaseUrl().startsWith('https://docs.ton.org');

type DocsConfig = {
redirects?: Redirect[];
};

const resolveBaseUrl = () => {
function resolveBaseUrl() {
const publicUrl = process.env.NEXT_PUBLIC_SITE_URL;
if (publicUrl !== undefined && publicUrl !== '') {
return publicUrl;
Expand All @@ -22,15 +22,15 @@ const resolveBaseUrl = () => {
}

return 'http://localhost:3000';
};
}

const loadDocsRedirects = (): Redirect[] => {
function loadDocsRedirects(): Redirect[] {
const docsConfig = JSON.parse(
readFileSync(new URL('./docs.json', import.meta.url), 'utf8'),
readFileSync(new URL('./docs.json', import.meta.url), 'utf8')
) as DocsConfig;

return docsConfig.redirects ?? [];
};
}

const config: NextConfig = {
reactStrictMode: true,
Expand Down