mirror of
https://github.com/fastapi/fastapi.git
synced 2026-06-18 12:29:59 -04:00
🔨 Update sponsors script to simplify previews (#15786)
This commit is contained in:
committed by
GitHub
parent
202b2d2f5f
commit
32d711f6d2
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user