diff --git a/docs/config.yml b/docs/config.yml index 340feb0aa6..4de0a7a4cf 100644 --- a/docs/config.yml +++ b/docs/config.yml @@ -95,7 +95,6 @@ extra: - icon: fontawesome/solid/square-rss name: BeeWare blog RSS feed link: https://beeware.org/news/buzz/atom.xml - github_icon: generator: false alternate: - name: English diff --git a/docs/macros.py b/docs/macros.py index 653c8ada44..f73054978e 100644 --- a/docs/macros.py +++ b/docs/macros.py @@ -1,9 +1,23 @@ import datetime +from functools import cache from pathlib import Path from textwrap import dedent +import material import yaml +# The Font Awesome icon set bundled with mkdocs-material +# This avoids the need for the Font Awesome kit/CDN). +FONTAWESOME_ICONS_DIR = ( + Path(material.__file__).parent / "templates" / ".icons" / "fontawesome" +) + + +@cache +def _fontawesome_svg(style, name): + """Load (and cache) the raw SVG markup for a bundled Font Awesome icon.""" + return (FONTAWESOME_ICONS_DIR / style / f"{name}.svg").read_text() + def attendees(authors, team): """Generates string identifying attendees of an event, based on whether there is @@ -40,10 +54,11 @@ def talk_title_punctuation(talk_title): def define_env(env): @env.macro - def fa(*tags): - """Generates the fontawesome HTML i element.""" - tags = " ".join(f"fa-{tag}" for tag in tags) - return f'' + def fa(style, name): + """Generates an inline Font Awesome icon, using the SVG bundled with + mkdocs-material, rather than depending on the Font Awesome kit/CDN. + """ + return f'{_fontawesome_svg(style, name)}' @env.macro def generate_resource_post(resource): @@ -252,7 +267,7 @@ def generate_team_members(team, page, current): try: mastodon = member_details["mastodon"].split("@") - member_image_details_mastodon = f"""
{fa("mastodon", "lg", "brands")} [{member_details["mastodon"]}](https://{mastodon[2]}/@{mastodon[1]})
""" # noqa: E501 + member_image_details_mastodon = f"""
{fa("brands", "mastodon")} [{member_details["mastodon"]}](https://{mastodon[2]}/@{mastodon[1]})
""" # noqa: E501 except KeyError: member_image_details_mastodon = "" @@ -261,7 +276,7 @@ def generate_team_members(team, page, current): ) try: - member_email_details = f"""
{fa("envelope", "lg", "solid")} <{member_details["email"]}>
""" # noqa: E501 + member_email_details = f"""
{fa("solid", "envelope")} <{member_details["email"]}>
""" # noqa: E501 except KeyError: member_email_details = "" @@ -272,8 +287,8 @@ def generate_team_members(team, page, current): ![{member_details["name"]}](/{member_details["avatar"]})
-
{fa("regular", pronoun_logo)} {first_pronoun}/{second_pronoun}
-
{fa("github", "lg", "brands")} [{github_id}](https://github.com/{github_id})
+
{fa("solid", pronoun_logo)} {first_pronoun}/{second_pronoun}
+
{fa("brands", "github")} [{github_id}](https://github.com/{github_id})
{member_image_details_mastodon} {member_email_details}