Skip to content

Commit 4534f6a

Browse files
authored
Addons: expose readthedocs.resolver.filename in the API response (#11940)
This is required to be able to dynamically update the URLs from the versions in the flyout when the page is changed using `history` object (without reloading / SPA) as Docusaurus does. In that scenario we cannot use the HTML META tag because it was injected with the old value by CF Worker. Note that the CF Worker is not run after the initial request on SPA. The addons frontend will use this attribute to update those URLs accordingly when the URL changes. Required by: * readthedocs/addons#504
1 parent e5c3714 commit 4534f6a

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

readthedocs/proxito/tests/responses/v1.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,9 @@
118118
"readthedocs": {
119119
"analytics": {
120120
"code": null
121+
},
122+
"resolver": {
123+
"filename": "/index.html"
121124
}
122125
},
123126
"addons": {

readthedocs/proxito/tests/test_hosting.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -667,6 +667,7 @@ def test_send_project_version_slugs(self):
667667
expected_response = self._get_response_dict("v1")
668668
# Remove `addons.doc_diff` from the response because it's not present when `url=` is not sent
669669
expected_response["addons"].pop("doc_diff")
670+
expected_response["readthedocs"]["resolver"]["filename"] = None
670671

671672
assert self._normalize_datetime_fields(r.json()) == expected_response
672673

readthedocs/proxito/views/hosting.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,9 @@ def _v1(self, project, version, build, filename, url, request):
452452
"analytics": {
453453
"code": settings.GLOBAL_ANALYTICS_CODE,
454454
},
455+
"resolver": {
456+
"filename": filename,
457+
},
455458
},
456459
# TODO: the ``features`` is not polished and we expect to change drastically.
457460
# Mainly, all the fields including a Project, Version or Build will use the exact same

0 commit comments

Comments
 (0)