Skip to content

Commit 647ba4f

Browse files
committed
Fix base urls
1 parent f4ec169 commit 647ba4f

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

.env.example

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1+
# Required: Set this URL to the base site URL where the app is hosted
2+
# Example: BASE_SITE_URL="https://redirectweb.net"
3+
BASE_SITE_URL=
4+
15
# Optional: Set this URL to redirect all pages to another domain
26
# Example: REDIRECTION_BASE_URL="https://redirectweb.net"
3-
# REDIRECTION_BASE_URL=
7+
REDIRECTION_BASE_URL=
48

59
# Optional: Set this path if the app is served from a subdirectory
6-
# Example: BASE_PATH="/redirect-web/"
10+
# Example: BASE_PATH="/"
711
BASE_PATH=

docusaurus.config.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,28 @@ if (!isSupportedLocale(locale)) {
1414
throw new Error(`Unsupported locale: ${locale}`);
1515
}
1616

17+
let baseSiteUrl: string;
18+
if (process.env.BASE_SITE_URL) {
19+
baseSiteUrl = process.env.BASE_SITE_URL;
20+
} else {
21+
console.warn('BASE_SITE_URL is not set. Using default value.');
22+
baseSiteUrl = `https://redirectweb.net`;
23+
}
24+
1725
const projectName = 'redirect-web';
1826
let baseUrl: string;
1927
if (process.env.BASE_PATH) {
2028
baseUrl = process.env.BASE_PATH;
2129
} else {
2230
console.warn('BASE_PATH is not set. Using default value.');
23-
baseUrl = `/${projectName}/`;
31+
baseUrl = `/`;
2432
}
2533
const localedBaseUrl = `${baseUrl}${locale == 'en' ? '' : `${locale}/`}`;
2634

2735
const config: Config = {
2836
title: 'RedirectWeb',
2937
tagline: translatedTagline(locale),
30-
url: 'https://mshibanami.github.io/',
38+
url: baseSiteUrl,
3139
favicon: '/img/icon/favicon.ico',
3240
headTags: [
3341
{ tagName: 'link', attributes: { rel: 'icon', type: 'image/png', sizes: '96x96', href: `${localedBaseUrl}img/icon/favicon-96x96.png` } },

scripts/build-prod.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@ while [[ "$#" -gt 0 ]]; do
1313
done
1414

1515
if [ "$environment" = "github" ]; then
16+
baseSiteUrl="https://mshibanami.github.io"
1617
basePath="/redirect-web/"
17-
redirectionBaseUrl="https://redirectweb.net/"
18+
redirectionBaseUrl="https://redirectweb.net"
1819
elif [ "$environment" = "cloudflare" ]; then
20+
baseSiteUrl="https://redirectweb.net"
1921
basePath="/"
2022
else
2123
echo "Unknown environment: $environment"
@@ -24,6 +26,6 @@ fi
2426

2527
rm -rf build
2628

27-
BASE_PATH="$basePath" REDIRECTION_BASE_URL="$redirectionBaseUrl" pnpm run build
29+
BASE_SITE_URL="$baseSiteUrl" BASE_PATH="$basePath" REDIRECTION_BASE_URL="$redirectionBaseUrl" pnpm run build
2830

2931
cp -R library build/

0 commit comments

Comments
 (0)