🔨 Update sponsors script to simplify previews (#15786)

This commit is contained in:
Sebastián Ramírez
2026-06-17 22:36:24 +02:00
committed by GitHub
parent 202b2d2f5f
commit 32d711f6d2
2 changed files with 23 additions and 19 deletions

View File

@@ -311,22 +311,26 @@ index_sponsors_template = """
### Keystone Sponsor
{% for sponsor in sponsors.keystone -%}
<a href="{{ sponsor.url }}" target="_blank" title="{{ sponsor.title }}"><img src="{{ sponsor.img }}"></a>
<a href="{{ sponsor.url }}" target="_blank" title="{{ sponsor.title }}"><img src="{{ sponsor_img_url(sponsor.img) }}"></a>
{% endfor %}
### Gold Sponsors
{% for sponsor in sponsors.gold -%}
<a href="{{ sponsor.url }}" target="_blank" title="{{ sponsor.title }}"><img src="{{ sponsor.img }}"></a>
<a href="{{ sponsor.url }}" target="_blank" title="{{ sponsor.title }}"><img src="{{ sponsor_img_url(sponsor.img) }}"></a>
{% endfor %}
### Silver Sponsors
{% for sponsor in sponsors.silver -%}
<a href="{{ sponsor.url }}" target="_blank" title="{{ sponsor.title }}"><img src="{{ sponsor.img }}"></a>
<a href="{{ sponsor.url }}" target="_blank" title="{{ sponsor.title }}"><img src="{{ sponsor_img_url(sponsor.img) }}"></a>
{% endfor %}
"""
def sponsor_img_url(img: str) -> str:
return f"https://fastapi.tiangolo.com{img}"
def remove_header_permalinks(content: str):
lines: list[str] = []
for line in content.split("\n"):
@@ -355,7 +359,7 @@ def generate_readme_content() -> str:
pre_end = match_start.end()
post_start = match_end.start()
template = Template(index_sponsors_template)
message = template.render(sponsors=sponsors)
message = template.render(sponsors=sponsors, sponsor_img_url=sponsor_img_url)
pre_content = content[frontmatter_end:pre_end]
post_content = content[post_start:]
new_content = pre_content + message + post_content