diff options
| author | Joe Mou <dev@mou.fo> | 2026-08-11 13:32:44 -0400 |
|---|---|---|
| committer | Joe Mou <dev@mou.fo> | 2026-08-11 17:37:02 -0400 |
| commit | 32ed69b43aeca42e88ab37187246e1035d4c933f (patch) | |
| tree | b11e637e784d96e285ffe43568d9d53f1def4911 /src/app.ts | |
| parent | d2c94ae32ff8d88f438d0e3348ca4f4a81f7bdd7 (diff) | |
Keep the ref picker on the current view and path
Diffstat (limited to 'src/app.ts')
| -rw-r--r-- | src/app.ts | 12 |
1 files changed, 9 insertions, 3 deletions
@@ -155,12 +155,18 @@ export function createApp(eta: Eta) { // be visited directly. Keep the site's initial page loads plain server- // rendered HTML while still surfacing data (branches/tags, latest commit) // that would otherwise require an extra scrape on every page view. - app.get("/api/:owner/:repo/refs/:type", async (c) => { - const { owner, repo, type } = c.req.param(); + // The view and path are where the picker was opened, so each ref can link to + // the same page on another ref. + app.get("/api/:owner/:repo/refs/:type/:view/:path{.*}?", async (c) => { + const { owner, repo, type, view, path = "" } = c.req.param(); if (type !== "branches" && type !== "tags") { return c.notFound(); } - return tryRenderFragment(c, "_refs.eta", getGitHubRefs(owner, repo, type)); + if (view !== "tree" && view !== "blob" && view !== "commits") { + return c.notFound(); + } + const refs = getGitHubRefs(owner, repo, type).then((data) => ({ ...data, view, path })); + return tryRenderFragment(c, "_refs.eta", refs); }); app.get("/api/:owner/:repo/latest-commit/:branch/:path{.*}?", async (c) => { |
