From 9823bb8aa75512cd38fcdca03430e793e6dc6581 Mon Sep 17 00:00:00 2001 From: Harish Mohan Raj Date: Sat, 21 Dec 2024 14:44:33 +0000 Subject: [PATCH 1/2] Add 404 page for redirection --- .github/workflows/deploy-website.yml | 37 +++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/.github/workflows/deploy-website.yml b/.github/workflows/deploy-website.yml index 0d5cd637d..3c82a1b2c 100644 --- a/.github/workflows/deploy-website.yml +++ b/.github/workflows/deploy-website.yml @@ -16,10 +16,11 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 - # Step 2: Create a fresh redirect HTML file + # Step 2: Create redirect HTML files - name: Create redirect HTML run: | mkdir -p dist + # Homepage redirect cat > dist/index.html << 'EOF' @@ -35,6 +36,40 @@ jobs: EOF + # Deep link handling + cat > dist/404.html << 'EOF' + + + + + + Page Redirection + + + If you are not redirected automatically, follow this link to the new documentation. + + + EOF + # Step 3: Deploy to gh-pages branch - name: Deploy to GitHub Pages uses: peaceiris/actions-gh-pages@v3 From a4c9d4af8ea5a7e81fa881001e8e10daed92ea02 Mon Sep 17 00:00:00 2001 From: Harish Mohan Raj Date: Sat, 21 Dec 2024 14:45:16 +0000 Subject: [PATCH 2/2] Add 404 page for redirection --- .github/workflows/deploy-website.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy-website.yml b/.github/workflows/deploy-website.yml index 3c82a1b2c..c6ee567b4 100644 --- a/.github/workflows/deploy-website.yml +++ b/.github/workflows/deploy-website.yml @@ -46,7 +46,7 @@ jobs: const newDomain = 'https://docs.ag2.ai'; let path = window.location.pathname; const hash = window.location.hash; - + // Remove /ag2/ prefix and trailing slash path = path.replace(/^\/ag2\//, '/').replace(/\/$/, ""); @@ -59,7 +59,7 @@ jobs: // Handle -index and create final URL with hash const redirectUrl = (newDomain + path).replace(/-index$/, "/index") + hash; - + window.location.href = redirectUrl; Page Redirection