File tree 1 file changed +8
-18
lines changed 1 file changed +8
-18
lines changed Original file line number Diff line number Diff line change 4
4
5
5
import docutils .nodes as nodes
6
6
from sphinx .application import Sphinx
7
+ from sphinx .errors import ConfigError
7
8
8
9
from .descriptionparser import get_description
9
10
from .titleparser import get_title
@@ -67,26 +68,15 @@ def get_tags(
67
68
# type tag
68
69
tags ["og:type" ] = config ["ogp_type" ]
69
70
70
- if os . getenv ( "READTHEDOCS" ) and config [ "ogp_site_url" ] is None :
71
- # readthedocs uses html_baseurl for sphinx > 1.8
72
- parse_result = urlparse ( config ["html_baseurl" ])
73
-
71
+ # url tag
72
+ # Get the canonical URL if ogp_site_url is not configured
73
+ if config ["ogp_site_url" ] is None :
74
+ # we require that either ogp_site_url or html_baseurl be configured
74
75
if config ["html_baseurl" ] is None :
75
- raise EnvironmentError ("ReadTheDocs did not provide a valid canonical URL!" )
76
-
77
- # Grab root url from canonical url
78
- config ["ogp_site_url" ] = urlunparse (
79
- (
80
- parse_result .scheme ,
81
- parse_result .netloc ,
82
- parse_result .path ,
83
- "" ,
84
- "" ,
85
- "" ,
86
- )
87
- )
76
+ raise ConfigError ("A URL has not been configured and is required as per the OpenGraph Specification!" )
77
+
78
+ config ["ogp_site_url" ] = config ["html_baseurl" ]
88
79
89
- # url tag
90
80
# Get the URL of the specific page
91
81
if context ["builder" ] == "dirhtml" :
92
82
page_url = urljoin (config ["ogp_site_url" ], context ["pagename" ] + "/" )
You can’t perform that action at this time.
0 commit comments