diff --git a/.gitignore b/.gitignore index 3b3679b..f6eb93d 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ __pycache__/ docs/dist/ requirements.txt app/_version.py +app/static/favicon.ico diff --git a/app/templates/layout.html b/app/templates/layout.html index c2b01bd..de6265f 100644 --- a/app/templates/layout.html +++ b/app/templates/layout.html @@ -8,6 +8,7 @@ + diff --git a/app/utils/favicon.py b/app/utils/favicon.py new file mode 100644 index 0000000..cc71132 --- /dev/null +++ b/app/utils/favicon.py @@ -0,0 +1,22 @@ +import sass # type: ignore +from PIL import Image +from PIL import ImageColor +from PIL import ImageDraw + + +def _get_primary_color() -> str: + """Small hack to get the theme primary color.""" + compiled = sass.compile( + string=( + "@import 'app/scss/main.scss';\n" + "#favicon-color { color: $primary-color; }" + ) + ) + return compiled[len(compiled) - 11 : -4] + + +def build_favicon() -> None: + """Builds a basic favicon with the theme primary color.""" + im = Image.new("RGB", (32, 32), ImageColor.getrgb(_get_primary_color())) + ImageDraw.Draw(im) + im.save("app/static/favicon.ico") diff --git a/docs/static/favicon.ico b/docs/static/favicon.ico new file mode 100644 index 0000000..19ac509 Binary files /dev/null and b/docs/static/favicon.ico differ diff --git a/docs/templates/layout.html b/docs/templates/layout.html index 2bda71d..f398f3c 100644 --- a/docs/templates/layout.html +++ b/docs/templates/layout.html @@ -74,7 +74,8 @@ footer { color: #555; } - + +