|
182 | 182 | # Run preprocessing on source files before makedocs() |
183 | 183 | preprocess_source_index() |
184 | 184 |
|
| 185 | +# Fix VitePress base path for dual deployment |
| 186 | +function fix_vitepress_base_path() |
| 187 | + deployment_target = get(ENV, "DEPLOYMENT_TARGET", "astroautomata") |
| 188 | + |
| 189 | + # Determine the correct base path for each deployment |
| 190 | + base_path = if deployment_target == "cambridge" |
| 191 | + "/symbolicregression/dev/" |
| 192 | + else |
| 193 | + "/SymbolicRegression.jl/dev/" |
| 194 | + end |
| 195 | + |
| 196 | + # Find and fix VitePress config files |
| 197 | + is_production = get(ENV, "DOCUMENTER_PRODUCTION", "false") == "true" |
| 198 | + build_subdir = is_production ? "1" : "." |
| 199 | + |
| 200 | + config_paths = [ |
| 201 | + joinpath(@__DIR__, "build", ".documenter", ".vitepress", "config.mts"), |
| 202 | + joinpath(@__DIR__, "build", build_subdir, ".vitepress", "config.mts"), |
| 203 | + ] |
| 204 | + |
| 205 | + for config_path in config_paths |
| 206 | + if isfile(config_path) |
| 207 | + @info "Fixing VitePress base path in $config_path for deployment target: $deployment_target" |
| 208 | + content = read(config_path, String) |
| 209 | + |
| 210 | + # Replace the base path with the correct one for this deployment |
| 211 | + # Look for existing base: '...' patterns and replace them |
| 212 | + content = replace(content, r"base:\s*'[^']*'" => "base: '$base_path'") |
| 213 | + |
| 214 | + write(config_path, content) |
| 215 | + @info "Updated VitePress base path to: $base_path" |
| 216 | + else |
| 217 | + @warn "VitePress config not found at: $config_path" |
| 218 | + end |
| 219 | + end |
| 220 | +end |
| 221 | + |
185 | 222 | # Configure deployment based on target |
186 | 223 | deployment_target = get(ENV, "DEPLOYMENT_TARGET", "astroautomata") |
187 | 224 |
|
@@ -223,11 +260,7 @@ makedocs(; |
223 | 260 | repo="github.com/MilesCranmer/SymbolicRegression.jl", |
224 | 261 | devbranch="master", |
225 | 262 | devurl="dev", |
226 | | - deploy_url=if deployment_target == "cambridge" |
227 | | - "https://ai.damtp.cam.ac.uk/symbolicregression" |
228 | | - else |
229 | | - "https://astroautomata.com/SymbolicRegression.jl" |
230 | | - end, |
| 263 | + deploy_url=nothing, # Will be handled by post-processing |
231 | 264 | deploy_decision, |
232 | 265 | build_vitepress=get(ENV, "DOCUMENTER_PRODUCTION", "false") == "true", |
233 | 266 | md_output_path=if get(ENV, "DOCUMENTER_PRODUCTION", "false") == "true" |
@@ -257,6 +290,9 @@ makedocs(; |
257 | 290 | # This runs after VitePress build to fix any final rendering issues |
258 | 291 | post_process_vitepress_index() |
259 | 292 |
|
| 293 | +# Fix VitePress base path for dual deployment |
| 294 | +fix_vitepress_base_path() |
| 295 | + |
260 | 296 | # Additional post-processing for VitePress production build issues |
261 | 297 | function fix_vitepress_production_output() |
262 | 298 | build_index_html = joinpath(@__DIR__, "build", "1", "index.html") |
|
0 commit comments