@@ -190,6 +190,14 @@ function fix_vitepress_base_path()
190190 " /SymbolicRegression.jl/dev/"
191191 end
192192
193+ # The version picker should link to sibling versions that live one
194+ # directory above the active version, e.g. `/symbolicregression/v1.12.0/`.
195+ # Compute that shared prefix (always the first path segment) so that we can
196+ # rewrite `__DEPLOY_ABSPATH__` accordingly.
197+ stripped = isempty (base_path) ? base_path : rstrip (base_path, ' /' )
198+ segments = split (stripped, ' /' ; keepempty= false )
199+ deploy_abspath = isempty (segments) ? " /" : " /" * first (segments) * " /"
200+
193201 # Find and fix VitePress SOURCE config file (before build)
194202 config_paths = [joinpath (@__DIR__ , " src" , " .vitepress" , " config.mts" )]
195203
@@ -201,9 +209,14 @@ function fix_vitepress_base_path()
201209 # Replace the base path with the correct one for this deployment
202210 # Look for existing base: '...' patterns and replace them
203211 content = replace (content, r" base:\s *'[^']*'" => " base: '$base_path '" )
212+ content = replace (
213+ content,
214+ r" __DEPLOY_ABSPATH__\s *:\s *JSON\. stringify\( '[^']*'\) " =>
215+ " __DEPLOY_ABSPATH__: JSON.stringify('$deploy_abspath ')" ,
216+ )
204217
205218 write (config_path, content)
206- @info " Updated VitePress base path to: $base_path "
219+ @info " Updated VitePress base path to: $base_path (deploy abspath: $deploy_abspath ) "
207220 else
208221 @warn " VitePress config not found at: $config_path "
209222 end
@@ -274,6 +287,20 @@ else
274287 )
275288end
276289
290+ current_version = let
291+ version = get (ENV , " DOCUMENTER_VERSION" , nothing )
292+ if version != = nothing && ! isempty (version)
293+ version
294+ else
295+ fallback = get (ENV , " DOCUMENTER_CURRENT_VERSION" , nothing )
296+ if fallback != = nothing && ! isempty (fallback)
297+ fallback
298+ else
299+ " dev"
300+ end
301+ end
302+ end
303+
277304DocMeta. setdocmeta! (
278305 SymbolicRegression,
279306 :DocTestSetup ,
@@ -284,6 +311,7 @@ DocMeta.setdocmeta!(
284311makedocs (;
285312 sitename= " SymbolicRegression.jl" ,
286313 authors= " Miles Cranmer" ,
314+ current_version= current_version,
287315 doctest= true ,
288316 clean= get (ENV , " DOCUMENTER_PRODUCTION" , " false" ) == " true" ,
289317 warnonly= [:docs_block , :cross_references , :missing_docs ],
0 commit comments