Skip to content

Commit 2537f47

Browse files
fix: always convert favicon defined in afterpython.toml to .ico when syncing with myst
1 parent ecaf601 commit 2537f47

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

  • src/afterpython/cli/commands

src/afterpython/cli/commands/sync.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from datetime import datetime
2+
from pathlib import PurePosixPath
23

34
import click
45
from pyproject_metadata import StandardMetadata
@@ -8,6 +9,13 @@
89
from afterpython.utils import convert_author_name_to_id, normalize_static_path
910

1011

12+
def _myst_favicon_path(path: str) -> str:
13+
"""Convert a website favicon path to MyST's required .ico favicon path."""
14+
if not path:
15+
return ""
16+
return str(PurePosixPath(path).with_suffix(".ico"))
17+
18+
1119
def _sync_authors_yml(authors: list[tuple[str, str | None]]):
1220
"""Sync authors.yml with authors in pyproject.toml"""
1321
from afterpython._io.yaml import read_yaml
@@ -58,10 +66,7 @@ def sync():
5866
website_favicon = normalize_static_path(
5967
str(_from_tomlkit(afterpython.get("website", {})).get("favicon", ""))
6068
)
61-
if website_favicon and not website_favicon.lower().endswith(".ico"):
62-
raise ValueError(
63-
f"Invalid favicon '{website_favicon}': mystmd only supports .ico files."
64-
)
69+
myst_favicon = _myst_favicon_path(website_favicon)
6570
website_logo = normalize_static_path(
6671
str(_from_tomlkit(afterpython.get("website", {})).get("logo", ""))
6772
)
@@ -133,7 +138,7 @@ def sync():
133138
"site": {
134139
"title": title,
135140
"options": {
136-
"favicon": "../static" + website_favicon if website_favicon else "",
141+
"favicon": "../static" + myst_favicon if myst_favicon else "",
137142
"logo": "../static" + website_logo if website_logo else "",
138143
"logo_dark": "../static" + website_logo_dark
139144
if website_logo_dark

0 commit comments

Comments
 (0)