Skip to content

Commit

Permalink
fix: don't use relative path to _static output folder (#46)
Browse files Browse the repository at this point in the history
* fix: don't use relative path to _static output folder

* fix: use only the name of the file

* fix: don't edit the favicon in _static_to_href

* fix don't use pathto

* set back pathto
  • Loading branch information
12rambau authored Mar 2, 2023
1 parent 24d9303 commit 4d90970
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions sphinx_favicon/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def _sizes(
return favicon


def _static_to_href(pathto: Callable, favicon: Dict[str, str]) -> Dict[str, str]:
def _static_to_href(pathto: Callable, init_favicon: Dict[str, str]) -> Dict[str, str]:
"""Replace static ref to fully qualified href.
if the ``href`` is a relative path then it's replaced with the correct ``href``. We keep checking for ``static-file`` for legacy reasons.
Expand All @@ -156,11 +156,14 @@ def _static_to_href(pathto: Callable, favicon: Dict[str, str]) -> Dict[str, str]
Args:
pathto: Sphinx helper_ function to handle relative URLs
favicon: The favicon description as set in the conf.py file
init_favicon: The favicon description as set in the conf.py file
Returns:
The favicon with a fully qualified href
"""
# work on a copy of the favicon (mutable issue)
favicon = init_favicon.copy()

# exit if the favicon tag has no href (like meta)
if not (FILE_FIELD in favicon or "href" in favicon):
return favicon
Expand All @@ -175,8 +178,7 @@ def _static_to_href(pathto: Callable, favicon: Dict[str, str]) -> Dict[str, str]

# if the link is absolute do nothing, else replace it with a full one
if not is_absolute:
path = f"{OUTPUT_STATIC_DIR}/{link}"
favicon["href"] = pathto(path, resource=True)
favicon["href"] = pathto(f"{OUTPUT_STATIC_DIR}/{link}", resource=True)

return favicon

Expand Down

0 comments on commit 4d90970

Please sign in to comment.