v0.5.115: add History routing and SEO prerender for Climperor Web.

Path URLs, crawlable hero/mechanics pages, and sitemap make the static site indexable while keeping SPA hydration.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
voson
2026-07-30 04:55:33 +08:00
co-authored by Cursor
parent 38f46ad2ea
commit 544ea42d40
16 changed files with 838 additions and 81 deletions
+22 -4
View File
@@ -1115,11 +1115,29 @@ class Handler(BaseHTTPRequestHandler):
return
rel = path.lstrip("/")
candidate = (WEB_DIR / rel).resolve()
if not str(candidate).startswith(str(WEB_DIR.resolve())) or not candidate.is_file():
self.send_error(404)
web_root = WEB_DIR.resolve()
if str(candidate).startswith(str(web_root)) and candidate.is_file():
ctype = mimetypes.guess_type(str(candidate))[0] or "application/octet-stream"
self._send(200, candidate.read_bytes(), ctype)
return
ctype = mimetypes.guess_type(str(candidate))[0] or "application/octet-stream"
self._send(200, candidate.read_bytes(), ctype)
# History SPA fallback: /heroes/axe → index.html (client router).
spa_pages = {
"heroes",
"rankings",
"matches",
"streamers",
"trends",
"mechanics",
"items",
"patches",
}
first = path.strip("/").split("/", 1)[0] if path.strip("/") else ""
if first in spa_pages:
index = WEB_DIR / "index.html"
if index.is_file():
self._send(200, index.read_bytes(), "text/html; charset=utf-8")
return
self.send_error(404)
def do_POST(self) -> None: # noqa: N802
path = urlparse(self.path).path