Skip to content

Commit

Permalink
Use Sphinx Builder method to get page url (#89)
Browse files Browse the repository at this point in the history
  • Loading branch information
attakei authored Dec 20, 2022
1 parent 7469f2b commit 5558484
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions sphinxext/opengraph/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,18 +90,9 @@ def get_tags(

# url tag
# Get the URL of the specific page
if context["builder"] == "dirhtml":
if context["pagename"] == "index":
page_url = config["ogp_site_url"]
elif context["pagename"].endswith("/index"):
relative = context["pagename"].rsplit("/", 1)[0]
page_url = urljoin(config["ogp_site_url"], relative + "/")
else:
page_url = urljoin(config["ogp_site_url"], context["pagename"] + "/")
else:
page_url = urljoin(
config["ogp_site_url"], context["pagename"] + context["file_suffix"]
)
page_url = urljoin(
config["ogp_site_url"], app.builder.get_target_uri(context["pagename"])
)
tags["og:url"] = page_url

# site name tag, False disables, default to project if ogp_site_name not
Expand Down

0 comments on commit 5558484

Please sign in to comment.