aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/app.ts5
-rw-r--r--views/layout.eta4
2 files changed, 6 insertions, 3 deletions
diff --git a/src/app.ts b/src/app.ts
index e34c7b1..5bed45d 100644
--- a/src/app.ts
+++ b/src/app.ts
@@ -44,7 +44,10 @@ export function createApp(eta: Eta) {
return c.html(eta.render("error.eta", { message: "" + e }));
}
}
- return c.html(eta.render(template, data));
+ // Our URLs mirror GitHub's, so the page we scraped is the same path there.
+ const { pathname, search } = new URL(c.req.url);
+ const githubUrl = `https://github.com${pathname}${search}`;
+ return c.html(eta.render(template, { ...data, githubUrl }));
}
// For fragments fetched asynchronously by client-side JS (see public/static/refs.js):
diff --git a/views/layout.eta b/views/layout.eta
index a80bd1d..f803caf 100644
--- a/views/layout.eta
+++ b/views/layout.eta
@@ -9,7 +9,7 @@
</head>
<body>
<div class="box">
- <div class="repo"><%= it.repo.owner %>/<%= it.repo.name %></div>
+ <div class="repo"><a href="/<%= it.repo.owner %>"><%= it.repo.owner %></a>/<a href="/<%= it.repo.owner %>/<%= it.repo.name %>"><%= it.repo.name %></a></div>
<pre><code>git clone https://github.com/<%= it.repo.owner %>/<%= it.repo.name %>.git
git clone git@github.com:<%= it.repo.owner %>/<%= it.repo.name %>.git</code></pre>
<nav>
@@ -34,7 +34,7 @@ git clone git@github.com:<%= it.repo.owner %>/<%= it.repo.name %>.git</code></pr
<%~ it.body %>
- <footer>Generated by cgithub</footer>
+ <footer>Generated by cgithub ยท <a href="<%= it.githubUrl %>" rel="noreferrer">View original</a></footer>
<script>
document.addEventListener("keydown", function(e) {