|
1 | 1 | from datetime import datetime |
| 2 | +from pathlib import PurePosixPath |
2 | 3 |
|
3 | 4 | import click |
4 | 5 | from pyproject_metadata import StandardMetadata |
|
8 | 9 | from afterpython.utils import convert_author_name_to_id, normalize_static_path |
9 | 10 |
|
10 | 11 |
|
| 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 | + |
11 | 19 | def _sync_authors_yml(authors: list[tuple[str, str | None]]): |
12 | 20 | """Sync authors.yml with authors in pyproject.toml""" |
13 | 21 | from afterpython._io.yaml import read_yaml |
@@ -58,10 +66,7 @@ def sync(): |
58 | 66 | website_favicon = normalize_static_path( |
59 | 67 | str(_from_tomlkit(afterpython.get("website", {})).get("favicon", "")) |
60 | 68 | ) |
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) |
65 | 70 | website_logo = normalize_static_path( |
66 | 71 | str(_from_tomlkit(afterpython.get("website", {})).get("logo", "")) |
67 | 72 | ) |
@@ -133,7 +138,7 @@ def sync(): |
133 | 138 | "site": { |
134 | 139 | "title": title, |
135 | 140 | "options": { |
136 | | - "favicon": "../static" + website_favicon if website_favicon else "", |
| 141 | + "favicon": "../static" + myst_favicon if myst_favicon else "", |
137 | 142 | "logo": "../static" + website_logo if website_logo else "", |
138 | 143 | "logo_dark": "../static" + website_logo_dark |
139 | 144 | if website_logo_dark |
|
0 commit comments