In src/sunpy_sphinx_theme/theme/sunpy/static/js/rtd_enhanced_search.js, getReadTheDocsResults builds the URL as /_/api/v3/search/?q=project:<slug>+<term> with no version parameter. RTD falls back to the project's default version (stable), so search results on /en/latest/ link to /en/stable/ pages.
This affects any project using the sunpy theme (including astropy, which inherits from it via the astropy-unified theme — see astropy/astropy#19866, closed in favor of this fix).
Repro: build docs on RTD on a non-stable branch, click a search result, URL shows /en/stable/.
Fix: capture versions.current.slug from the readthedocs-addons-data-ready event, append &version=<slug> to the query. Patch is small, ~6 lines in rtd_enhanced_search.js.
In
src/sunpy_sphinx_theme/theme/sunpy/static/js/rtd_enhanced_search.js,getReadTheDocsResultsbuilds the URL as/_/api/v3/search/?q=project:<slug>+<term>with no version parameter. RTD falls back to the project's default version (stable), so search results on /en/latest/ link to /en/stable/ pages.This affects any project using the sunpy theme (including astropy, which inherits from it via the astropy-unified theme — see astropy/astropy#19866, closed in favor of this fix).
Repro: build docs on RTD on a non-stable branch, click a search result, URL shows /en/stable/.
Fix: capture
versions.current.slugfrom thereadthedocs-addons-data-readyevent, append&version=<slug>to the query. Patch is small, ~6 lines in rtd_enhanced_search.js.