Skip to content

Pin RTD search query to current version#328

Open
karlhillx wants to merge 1 commit into
sunpy:mainfrom
karlhillx:fix/327-rtd-search-version
Open

Pin RTD search query to current version#328
karlhillx wants to merge 1 commit into
sunpy:mainfrom
karlhillx:fix/327-rtd-search-version

Conversation

@karlhillx

Copy link
Copy Markdown

Fixes #327.

getReadTheDocsResults was hitting /_/api/v3/search/ without a version parameter, so RTD fell back to the project's default version (usually stable). On any non-stable build (latest, a release branch, a PR preview) the search box returned results linking to /en/stable/ instead of the version being read.

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.

The change captures versions.current.slug from the readthedocs-addons-data-ready event and appends &version=<slug> to the search URL. The capture is wrapped in a try/catch so a missing event detail (e.g. local builds) leaves _rtdVersion null and the existing behavior is preserved.

The v3 search API call in getReadTheDocsResults was missing the version
parameter, so RTD defaulted to the project's default version (stable).
On non-stable builds (latest, a release branch, a PR build) search
results linked to /en/stable/ pages instead of the version being read.

Capture versions.current.slug from the readthedocs-addons-data-ready
event and append &version=<slug> to the query.

Fixes sunpy#327.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

rtd_enhanced_search.js hits v3 API without version, RTD returns stable results on non-stable builds

1 participant