diff options
| author | Joe Mou <dev@mou.fo> | 2026-08-11 08:09:47 -0400 |
|---|---|---|
| committer | Joe Mou <dev@mou.fo> | 2026-08-11 08:13:58 -0400 |
| commit | b43ce92c7b16bdefedb7c4c2aef41f9417f1ddf6 (patch) | |
| tree | 29ff6b47a16e62a58e17921f2c1200249c1845c0 /src/app.ts | |
| parent | ecd01c4617ec0a6af05cfc4388bdc82986f25961 (diff) | |
Add language percentages to repo pages
GitHub no longer server-renders the repository sidebar; its React UI
lazily fetches /:owner/:repo/_sidebar as JSON, which carries the
language breakdown (name, percentage, color). getGitHubLanguages() uses
that endpoint, and a new /api/:owner/:repo/languages fragment route
renders the bar and legend the same way refs and latest-commit already
work, so repo page loads still cost a single scrape.
The latest-commit placeholder loader in refs.js is generalized over
.placeholder[data-src] so both placeholders share it.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Diffstat (limited to 'src/app.ts')
| -rw-r--r-- | src/app.ts | 6 |
1 files changed, 6 insertions, 0 deletions
@@ -5,6 +5,7 @@ import { getGitHubBlob, getGitHubCommits, getGitHubIssues, + getGitHubLanguages, getGitHubLatestCommit, getGitHubOwner, getGitHubPulls, @@ -158,6 +159,11 @@ export function createApp(eta: Eta) { ); }); + app.get("/api/:owner/:repo/languages", async (c) => { + const { owner, repo } = c.req.param(); + return tryRenderFragment(c, "_languages.eta", getGitHubLanguages(owner, repo)); + }); + app.get("/:owner/:repo/releases/tag/:tag", async (c) => { const { owner, repo, tag } = c.req.param(); return tryRender(c, "release.eta", getGitHubRelease(owner, repo, tag)); |
