Add GitHub corner link to source files

Octocat banner in the upper right links to the .md source file for each
page. Directory indexes link to index.md, regular pages to their .md,
and the homepage falls back to the repo root.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-11 22:41:30 -04:00
parent 12501dfa6c
commit 33ea221a12
4 changed files with 51 additions and 0 deletions
+2
View File
@@ -1483,6 +1483,7 @@ async def catch_all(req, resp, *, path):
content=content_data["content"],
title=content_data["title"],
metadata=content_data.get("metadata", {}),
github_file=f"data/{path}.md",
reading_time=content_data.get("reading_time"),
word_count=content_data.get("word_count"),
tags=content_data.get("tags", []),
@@ -1553,6 +1554,7 @@ async def catch_all(req, resp, *, path):
metadata=content_data.get("metadata", {}),
items=items,
current_path=f"/{path}",
github_file=f"data/{path}/index.md",
current_year=datetime.now().year,
reading_time=content_data.get("reading_time"),
word_count=content_data.get("word_count"),
+2
View File
@@ -440,6 +440,7 @@ def serve_content(path):
metadata=content_data["metadata"],
items=items,
current_path=f"/{path}",
github_file=f"data/{path}/index.md",
current_year=datetime.now().year,
reading_time=content_data.get("reading_time"),
word_count=content_data.get("word_count"),
@@ -581,6 +582,7 @@ def serve_content(path):
title=content_data["title"],
metadata=content_data["metadata"],
current_path=f"/{path}",
github_file=f"data/{path}.md",
current_year=datetime.now().year,
reading_time=content_data.get("reading_time"),
word_count=content_data.get("word_count"),
+5
View File
@@ -0,0 +1,5 @@
<svg xmlns="http://www.w3.org/2000/svg" width="80" height="80" viewBox="0 0 250 250" fill="#fff">
<path d="M0 0l115 115h15l12 27 108 108V0z" fill="#151513"/>
<path d="M128 109c-15-9-9-19-9-19 3-7 2-11 2-11-1-7 3-2 3-2 4 5 2 11 2 11-3 10 5 15 9 16"/>
<path d="M115 115s4 2 5 0l14-14c3-2 6-3 8-3-8-11-15-24 2-41 5-5 10-7 16-7 1-2 3-7 12-11 0 0 5 3 7 16 4 2 8 5 12 9s7 8 9 12c14 3 17 7 17 7-4 8-9 11-11 11 0 6-2 11-7 16-16 16-30 10-41 2 0 3-1 7-5 11l-12 11c-1 1 1 5 1 5z"/>
</svg>

After

Width:  |  Height:  |  Size: 490 B

+42
View File
@@ -183,6 +183,39 @@
}
}
.github-corner {
position: fixed;
top: 0;
right: 0;
z-index: 9998;
opacity: 0.85;
transition: opacity 0.3s ease;
}
.github-corner:hover {
opacity: 0.8;
}
.github-corner-img {
width: 80px;
height: 80px;
}
body.dark-mode .github-corner {
opacity: 0.25;
}
body.dark-mode .github-corner-img {
filter: invert(1);
}
@media (max-width: 760px) {
.github-corner-img {
width: 50px;
height: 50px;
}
}
.theme-toggle {
position: fixed;
bottom: 2rem;
@@ -409,6 +442,15 @@
<!-- Reading progress bar -->
<div class="reading-progress" id="reading-progress"></div>
{% set github_base = 'https://github.com/kennethreitz/kennethreitz.org' %}
{% if github_file %}
<a href="{{ github_base }}/blob/main/{{ github_file }}" class="github-corner" aria-label="View source on GitHub" target="_blank">
{% else %}
<a href="{{ github_base }}" class="github-corner" aria-label="View source on GitHub" target="_blank">
{% endif %}
<img src="/static/images/github-banner.svg" alt="View on GitHub" class="github-corner-img">
</a>
<button id="theme-toggle" class="theme-toggle" aria-label="Toggle dark mode">
<span class="sun-icon">☀️</span>
<span class="moon-icon">🌙</span>