Skip to content

Commit 170997c

Browse files
committed
fix redirect url
Signed-off-by: Aritra Dey <[email protected]>
1 parent 1e812af commit 170997c

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

.github/workflows/publish-docs.yml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,27 @@ jobs:
3232
with:
3333
node-version: 20
3434

35-
- name: Calculate BASE_URL
35+
- name: Calculate URLs
3636
run: |
37-
if [[ "${{ github.event.repository.name }}" == "${{ github.repository_owner }}.github.io" ]]; then
37+
REPO="${{ github.event.repository.name }}"
38+
OWNER="${{ github.repository_owner }}"
39+
40+
if [[ "$REPO" == "$OWNER.github.io" ]]; then
41+
# User/org GitHub Pages repo
3842
echo "BASE_URL=/pr-preview/pr-${{ github.event.pull_request.number }}/" >> $GITHUB_ENV
43+
echo "URL=https://$OWNER.github.io" >> $GITHUB_ENV
3944
else
40-
echo "BASE_URL=/${{ github.event.repository.name }}/pr-preview/pr-${{ github.event.pull_request.number }}/" >> $GITHUB_ENV
45+
# Normal project repo (fork or upstream)
46+
echo "BASE_URL=/$REPO/pr-preview/pr-${{ github.event.pull_request.number }}/" >> $GITHUB_ENV
47+
echo "URL=https://$OWNER.github.io/$REPO" >> $GITHUB_ENV
4148
fi
4249
50+
4351
- name: Install and Build
4452
run: npm ci && npm run build
4553
env:
4654
BASE_URL: ${{ env.BASE_URL }}
55+
URL: ${{ env.URL }}
4756

4857
- name: Deploy Preview
4958
uses: rossjrw/pr-preview-action@v1

docusaurus.config.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ module.exports = {
33
title: "PEcAn Project",
44
tagline:
55
"Ecosystem science, policy, and management informed by the best available data and models",
6-
url: "https://pecanproject.github.io",
6+
url: process.env.URL || "https://pecanproject.github.io",
77
baseUrl: process.env.BASE_URL || "/",
88
onBrokenLinks: "ignore",
99
onBrokenMarkdownLinks: "warn",
1010
favicon: "img/favicon.ico",
11-
organizationName: "PecanProject", // Usually your GitHub org/user name.
12-
projectName: "PecanProject.github.io", // Usually your repo name.
11+
organizationName: process.env.GITHUB_OWNER || "PecanProject", // Usually your GitHub org/user name.
12+
projectName: process.env.GITHUB_REPOSITORY || "PecanProject.github.io", // Usually your repo name.
1313
themeConfig: {
1414
navbar: {
1515
title: "PEcAn",

0 commit comments

Comments
 (0)