refactor(docs): migrate documentation to Blume and restructure content

This commit is contained in:
Prad Nukala committed 2026-08-14 13:15:38 -04:00
1 parent a3c1049bee
commit 5d69dee4d8
30 files changed
+240 -407

No files matched your search

+28
View File
@@ -0,0 +1,28 @@
export default {
async fetch(request, env) {
const auth = request.headers.get("Authorization") ?? "";
if (auth.startsWith("Basic ")) {
let ok = false;
try {
const decoded = atob(auth.slice(6));
const password = decoded.slice(decoded.indexOf(":") + 1); // password may contain ':'
ok = await passwordMatches(password, env.SITE_PASSWORD);
} catch {}
if (ok) return env.ASSETS.fetch(request);
}
return new Response("Authentication required", {
status: 401,
headers: { "WWW-Authenticate": 'Basic realm="leetcode-docs", charset="UTF-8"' },
});
},
};
// timingSafeEqual needs equal-length buffers → hash both sides first
async function passwordMatches(candidate, expected) {
const enc = new TextEncoder();
const [a, b] = await Promise.all([
crypto.subtle.digest("SHA-256", enc.encode(candidate)),
crypto.subtle.digest("SHA-256", enc.encode(expected)),
]);
return crypto.subtle.timingSafeEqual(a, b);
}