Skip to content

Commit

Permalink
Allow dirhtml builder without ogp_site_url
Browse files Browse the repository at this point in the history
- Yes, the readme says that ogp_site_url is very important.  And
  indeed, reports online say that OGP doesn't work with relative URLs.
  Although at least one place says it does...
- Yet, I got confused when I could build it with html (it left
  everything relative), but not with dirhtml (obscure extension error
  it took me a while to figure out).  (And it only fails on the page
  named `/index`.
- Set the default ogp_site_url to "" by default, instead of None, to
  make relative by default (previous behavior) instead of raising an
  exception.
- Even if this isn't perfect, it helps a bit with "make this extension
  do something useful, even if not perfect, if it's installed but not
  configured".
- So overall, even though this isn't a perfect change, and could be
  considered technically incorrect, I think it's less confusing and
  makes things more consistent for a possibly better solution later.
  • Loading branch information
rkdarst committed Nov 8, 2022
1 parent b9f1dea commit 756d9e9
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion sphinxext/opengraph/__init__.py
Expand Up @@ -193,7 +193,9 @@ def html_page_context(


def setup(app: Sphinx) -> Dict[str, Any]:
app.add_config_value("ogp_site_url", None, "html")
# ogp_site_url="" allows relative by default, even though it's not
# officially supported by OGP.
app.add_config_value("ogp_site_url", "", "html")
app.add_config_value("ogp_description_length", DEFAULT_DESCRIPTION_LENGTH, "html")
app.add_config_value("ogp_image", None, "html")
app.add_config_value("ogp_image_alt", None, "html")
Expand Down

0 comments on commit 756d9e9

Please sign in to comment.