@@ -33,25 +33,54 @@ jobs:
3333 - name : Build Documentation
3434 run : make docs-generate REPO_NAME=math DOCS_VERSION_PATH=main
3535
36- - name : Add Root Redirect
36+ - name : Setup Redirects
3737 run : |
38- cat <<EOF > .build/documentation/index.html
38+ # Function to create a redirect file
39+ create_redirect() {
40+ local FILE_PATH=$1
41+ local TARGET_URL=$2
42+ local TITLE=$3
43+
44+ mkdir -p "$(dirname "$FILE_PATH")"
45+
46+ cat <<EOF > "$FILE_PATH"
3947 <!DOCTYPE html>
4048 <html>
4149 <head>
4250 <meta charset="utf-8">
43- <title>Redirecting to Documentation </title>
44- <link rel="canonical" href="main/documentation/fireblademath/index.html ">
51+ <title>$TITLE </title>
52+ <link rel="canonical" href="$TARGET_URL ">
4553 <script>
46- window.location.href = "main/documentation/fireblademath/index.html " + window.location.hash;
54+ window.location.href = "$TARGET_URL " + window.location.hash;
4755 </script>
48- <meta http-equiv="refresh" content="0;url=main/documentation/fireblademath/index.html ">
56+ <meta http-equiv="refresh" content="0;url=$TARGET_URL ">
4957 </head>
5058 <body>
51- <p>Redirecting to <a href="main/documentation/fireblademath/index.html">documentation </a>...</p>
59+ <p>Redirecting to <a href="$TARGET_URL">$TITLE </a>...</p>
5260 </body>
5361 </html>
5462 EOF
63+ }
64+
65+ # 1. Root -> latest/documentation/fireblademath/
66+ create_redirect ".build/documentation/index.html" \
67+ "latest/documentation/fireblademath/index.html" \
68+ "Redirecting to Latest Docs"
69+
70+ # 2. latest/ -> main/documentation/fireblademath/
71+ create_redirect ".build/documentation/latest/index.html" \
72+ "../main/documentation/fireblademath/index.html" \
73+ "Redirecting to Main Docs"
74+
75+ # 3. latest/documentation/fireblademath/ -> main/documentation/fireblademath/
76+ create_redirect ".build/documentation/latest/documentation/fireblademath/index.html" \
77+ "../../../main/documentation/fireblademath/index.html" \
78+ "Redirecting to Main Docs"
79+
80+ # 4. documentation/fireblademath/ -> main/documentation/fireblademath/
81+ create_redirect ".build/documentation/documentation/fireblademath/index.html" \
82+ "../../main/documentation/fireblademath/index.html" \
83+ "Redirecting to Main Docs"
5584
5685 - name : Check Documentation Quality
5786 run : |
86115 # Wait a few seconds for CDN propagation
87116 sleep 10
88117 # Verify the versioned documentation path exists
89- curl --fail -sL https://fireblade-engine.github.io/math/main/documentation/fireblademath/ | grep -q "FirebladeMath "
118+ curl --fail -sL https://fireblade-engine.github.io/math/main/documentation/fireblademath/ | grep -q "Documentation "
90119 echo "Documentation is live at /math/main/"
91120
92121 - name : Check Root Redirect
95124 RESPONSE=$(curl -sI https://fireblade-engine.github.io/math/ | head -n 1)
96125 # Note: GitHub Pages might return 200 with the redirect meta tag, or a 301/302 if configured at the DNS level.
97126 # Since we use a meta/JS redirect, we check for a 200 OK and then the content.
98- curl -s https://fireblade-engine.github.io/math/ | grep -q "Redirecting to"
99- echo "Root redirect is live at /math/"
127+ curl -s https://fireblade-engine.github.io/math/ | grep -q "Redirecting to Latest Docs "
128+ echo "Root redirect is live at /math/ and points to latest docs "
0 commit comments