Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion SPONSORSHIP.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Your sponsorship puts your product in front of developers at the exact moment th

## Get Started

Email [vinta.chen@gmail.com](mailto:vinta.chen@gmail.com?subject=Awesome%20Python%20Sponsorship) with:
Email [sponsorship@awesome-python.com](mailto:sponsorship@awesome-python.com?subject=Awesome%20Python%20Sponsorship) with:

- **Tier:** Headline Sponsor ($500/mo) or Featured Sponsor ($150/mo)
- **Content:** Product name, URL, logo, and description (Headline tier) or `[Name](URL) - Description.` entry (Featured tier)
Expand Down
35 changes: 34 additions & 1 deletion website/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,36 @@ def extract_categories_body(markdown: str) -> str:
return "".join(lines[start_idx:end_idx]).rstrip() + "\n"


def github_markdown_anchor(text: str) -> str:
anchor = text.strip().lower()
anchor = re.sub(r"[^\w\s-]", "", anchor)
anchor = re.sub(r"\s", "-", anchor)
return f"#{anchor}"


def link_llms_category_index_to_canonical_pages(markdown: str, categories: Sequence[ParsedSection]) -> str:
"""Point the README-derived category index at canonical category pages."""
category_urls = {}
for category in categories:
public_url = category_public_url(category)
category_urls[f"#{category['slug']}"] = public_url
category_urls[github_markdown_anchor(category["name"])] = public_url
lines = markdown.splitlines(keepends=True)
out: list[str] = []

def replace_link(match: re.Match[str]) -> str:
target = match.group(1)
url = category_urls.get(target)
if url is None:
return match.group(0)
return match.group(0).replace(f"({target})", f"({url})", 1)

for line in lines:
out.append(MARKDOWN_LINK_RE.sub(replace_link, line))

return "".join(out)


def build_llms_txt(
template_text: str,
*,
Expand All @@ -280,7 +310,10 @@ def build_llms_txt(
) -> str:
"""Render the llms.txt entry point with the curated category catalog."""
categories_md = annotate_entries_with_stars(
extract_categories_body(readme_text).rstrip(),
link_llms_category_index_to_canonical_pages(
extract_categories_body(readme_text).rstrip(),
categories,
),
stars_data,
format_stars=lambda n: f"GitHub stars: {n}",
)
Expand Down
16 changes: 8 additions & 8 deletions website/templates/sponsorship.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ <h1>Sponsor Awesome Python</h1>

<div class="hero-actions">
<a
href="mailto:vinta.chen@gmail.com?subject=Awesome%20Python%20Sponsorship"
href="mailto:sponsorship@awesome-python.com?subject=Awesome%20Python%20Sponsorship"
class="hero-action hero-action-primary"
>Email vinta.chen@gmail.com</a
>Email sponsorship@awesome-python.com</a
>
<a
href="https://github.com/vinta/awesome-python"
Expand Down Expand Up @@ -123,7 +123,7 @@ <h1>Sponsor Awesome Python</h1>
<li>Logo link in the sponsor section of awesome-python.com.</li>
</ul>
<a
href="mailto:vinta.chen@gmail.com?subject=Awesome%20Python%20Sponsorship%20-%20Headline"
href="mailto:sponsorship@awesome-python.com?subject=Awesome%20Python%20Sponsorship%20-%20Headline"
class="tier-cta"
>Email about Headline tier</a
>
Expand All @@ -146,7 +146,7 @@ <h1>Sponsor Awesome Python</h1>
<li>Text link in the sponsor section of awesome-python.com.</li>
</ul>
<a
href="mailto:vinta.chen@gmail.com?subject=Awesome%20Python%20Sponsorship%20-%20Featured"
href="mailto:sponsorship@awesome-python.com?subject=Awesome%20Python%20Sponsorship%20-%20Featured"
class="tier-cta"
>Email about Featured tier</a
>
Expand Down Expand Up @@ -185,8 +185,8 @@ <h1>Sponsor Awesome Python</h1>
<p class="sponsorship-lede">
Email
<a
href="mailto:vinta.chen@gmail.com?subject=Awesome%20Python%20Sponsorship"
>vinta.chen@gmail.com</a
href="mailto:sponsorship@awesome-python.com?subject=Awesome%20Python%20Sponsorship"
>sponsorship@awesome-python.com</a
>
with the four items below.
</p>
Expand All @@ -213,9 +213,9 @@ <h1>Sponsor Awesome Python</h1>
</dl>
<div class="sponsorship-cta-row">
<a
href="mailto:vinta.chen@gmail.com?subject=Awesome%20Python%20Sponsorship"
href="mailto:sponsorship@awesome-python.com?subject=Awesome%20Python%20Sponsorship"
class="hero-action hero-action-primary"
>Email vinta.chen@gmail.com</a
>Email sponsorship@awesome-python.com</a
>
</div>
</div>
Expand Down
3 changes: 2 additions & 1 deletion website/tests/test_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,8 @@ def test_build_creates_llms_text_alternate_without_sponsors(self, tmp_path):
assert "Sitemap: https://awesome-python.com/sitemap.xml" in llms_txt
assert "## Categories" in llms_txt
assert "**Tools**" in llms_txt
assert "- [Widgets](#widgets)" in llms_txt
assert "- [Widgets](https://awesome-python.com/categories/widgets/)" in llms_txt
assert "- [Widgets](#widgets)" not in llms_txt
assert "### Widgets" in llms_txt
assert "- [w1](https://example.com) - A widget." in llms_txt
assert "- [w2](https://github.com/owner/w2) - A starred widget. (GitHub stars: 42)" in llms_txt
Expand Down