File tree Expand file tree Collapse file tree 1 file changed +11
-7
lines changed
Expand file tree Collapse file tree 1 file changed +11
-7
lines changed Original file line number Diff line number Diff line change 11from typing import Any , Dict
2- from urllib .parse import urljoin , urlparse , urlunparse
2+ from urllib .parse import urljoin , urlparse , urlsplit , urlunparse
33from pathlib import Path
44
55import docutils .nodes as nodes
@@ -86,12 +86,16 @@ def get_tags(
8686 # type tag
8787 tags ["og:type" ] = config ["ogp_type" ]
8888
89- if os .getenv ("READTHEDOCS" ) and not config ["ogp_site_url" ]:
90- # readthedocs uses html_baseurl for sphinx > 1.8
91- parse_result = urlparse (config ["html_baseurl" ])
92-
93- if config ["html_baseurl" ] is None :
94- raise OSError ("ReadTheDocs did not provide a valid canonical URL!" )
89+ if not config ["ogp_site_url" ] and os .getenv ("READTHEDOCS" ):
90+ if config ["html_baseurl" ] is not None :
91+ # readthedocs uses ``html_baseurl`` for Sphinx > 1.8
92+ parse_result = urlsplit (config ["html_baseurl" ])
93+ else :
94+ # readthedocs addons no longer configures ``html_baseurl``
95+ if rtd_canonical_url := os .getenv ("READTHEDOCS_CANONICAL_URL" ):
96+ parse_result = urlsplit (rtd_canonical_url )
97+ else :
98+ raise OSError ("ReadTheDocs did not provide a valid canonical URL!" )
9599
96100 # Grab root url from canonical url
97101 config ["ogp_site_url" ] = urlunparse (
You can’t perform that action at this time.
0 commit comments