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'' @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"""