File tree 1 file changed +11
-7
lines changed
1 file changed +11
-7
lines changed Original file line number Diff line number Diff line change 1
1
from typing import Any , Dict
2
- from urllib .parse import urljoin , urlparse , urlunparse
2
+ from urllib .parse import urljoin , urlparse , urlsplit , urlunparse
3
3
from pathlib import Path
4
4
5
5
import docutils .nodes as nodes
@@ -86,12 +86,16 @@ def get_tags(
86
86
# type tag
87
87
tags ["og:type" ] = config ["ogp_type" ]
88
88
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!" )
95
99
96
100
# Grab root url from canonical url
97
101
config ["ogp_site_url" ] = urlunparse (
You can’t perform that action at this time.
0 commit comments