This repository hosts a minimal, dependency-light blog built with React via CDN, Markdown for posts, and KaTeX for math. Designed for GitHub Pages, no build step is required.
- Simple React SPA with hash routing (
#/and#/post/:slug) - Dark: Catppuccin Mocha • Light: AnuPpuccin-inspired
- Markdown posts fetched from
/posts/*.md - KaTeX auto-render for
$..$and$$..$$
index.html— entry with CDN scripts and CSSassets/styles.css— theme variables and layoutassets/app.js— SPA logic, routing, markdown + math renderingposts/index.json— post manifest (slug, title, date, file, ...)posts/*.md— markdown source for each post404.html— redirect fallback for GitHub Pages
-
Add a Markdown file under
posts/your-post.md. -
Update
posts/index.jsonwith an object:{ "slug": "your-post", "title": "Your Post Title", "date": "2025-09-15", "tags": ["deep-learning"], "summary": "Optional summary.", "file": "posts/your-post.md" } -
Open
#/post/your-postto view it.
Use $inline$ or $$display$$ LaTeX delimiters. KaTeX auto-render is included via CDN in index.html.
Theme toggle persists preference (localStorage). Variables live in assets/styles.css under html[data-theme="dark"] (Mocha) and html[data-theme="light"] (AnuPpuccin). The Rationale font is loaded from Google Fonts.
Serve the folder locally (any static server). Example with Python:
python3 -m http.server -b 127.0.0.1 8080Then visit http://127.0.0.1:8080.
Both comments and engagement counters are optional; the UI hides itself when configuration is missing.
- Follow https://giscus.app to generate repository, category, and ID values.
- Populate the
window.__BLOG_GISCUSobject inindex.htmlwith the values that giscus provides (repo,repoId,category,categoryId, optional custom themes). - The SPA automatically mounts giscus at the end of every post and keeps the embedded theme in sync with the site toggle.
- Create (or choose) a GitHub repository to store metrics. Open an issue and add a comment whose body is
{ "slugs": {} }. Note the numeric comment ID. - Deploy the Cloudflare Worker in
workers/github-metrics.jswithwrangler. The worker expects these environment variables:GITHUB_TOKEN— fine-grained PAT withissues:readandissues:writeon the repo above.GITHUB_OWNER/GITHUB_REPO— repository that holds the metrics comment.GITHUB_COMMENT_ID— ID of the comment created in step 1.
- Set the worker's public URL as
window.__BLOG_METRICS.baseUrlinindex.html. - Each page view sends
POST /view; clicking the like chip sendsPOST /like. Both endpoints update the JSON stored inside the GitHub comment, so values are permanent and versioned in GitHub. A lightweightGET /metrics?slug=...keeps the UI in sync. - The client also stores a
localStorageflag (post:liked:slug) to prevent accidental repeat likes from the same browser.