Skip to content

Commit

Permalink
fixing bug in edit button
Browse files Browse the repository at this point in the history
  • Loading branch information
choldgraf committed Apr 25, 2020
1 parent 96f177f commit 38aae8d
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions sphinx_book_theme/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,17 +202,19 @@ def nav_to_html_list(
if doctree and context.get("page_source_suffix"):
config_theme = app.config.html_theme_options
repo_url = config_theme.get("repository_url", "")
branch = config_theme.get("repository_branch", "")
relpath = config_theme.get("path_to_docs", "")
org, repo = repo_url.strip("/").split("/")[-2:]
context.update(
{
"github_user": org,
"github_repo": repo,
"github_version": branch,
"doc_path": relpath,
}
)
# Only add the edit button if `repository_url` is given
if repo_url:
branch = config_theme.get("repository_branch", "")
relpath = config_theme.get("path_to_docs", "")
org, repo = repo_url.strip("/").split("/")[-2:]
context.update(
{
"github_user": org,
"github_repo": repo,
"github_version": branch,
"doc_path": relpath,
}
)
else:
# Disable using the button so we don't get errors
context["theme_use_edit_page_button"] = False
Expand Down

0 comments on commit 38aae8d

Please sign in to comment.