Skip to content

Commit

Permalink
Merge pull request #269 from harishmohanraj/main
Browse files Browse the repository at this point in the history
Set up redirects from gh-pages to new domain
  • Loading branch information
davorrunje authored Dec 21, 2024
2 parents 3ecb566 + 8b408f2 commit 17ab5d6
Showing 1 changed file with 36 additions and 1 deletion.
37 changes: 36 additions & 1 deletion .github/workflows/deploy-website.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
<!DOCTYPE html>
<html>
Expand All @@ -35,6 +36,40 @@ jobs:
</html>
EOF
# Deep link handling
cat > dist/404.html << 'EOF'
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<script>
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(/\/$/, "");
// Transform blog and talks URLs
if (path.includes('/blog/') || path.includes('/talks/')) {
const afterPrefix = path.split(/\/(blog|talks)\//)[2];
const transformed = afterPrefix.replace(/\//g, '-');
path = path.replace(afterPrefix, transformed);
}
// Handle -index and create final URL with hash
const redirectUrl = (newDomain + path).replace(/-index$/, "/index") + hash;
window.location.href = redirectUrl;
</script>
<title>Page Redirection</title>
</head>
<body>
If you are not redirected automatically, follow this <a href="https://docs.ag2.ai">link to the new documentation</a>.
</body>
</html>
EOF
# Step 3: Deploy to gh-pages branch
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
Expand Down

0 comments on commit 17ab5d6

Please sign in to comment.