Skip to content

About

My 🏑 in the ☁: blog and portfolio of Trong Khanh (Karhdo). v2 on Astro Γ— Bun, Tailwind v4 and Tokyonight; v1 (Next.js) lives on the v1 branch.

Topics

Resources

Stars

80 stars

Watchers

1 watching

Forks

Latest commit

Β 

History

237 Commits

Folders and files

Repository files navigation

Karhdo's Coding Adventure

My desire to practice my skills and share my acquired knowledge fuels my endeavors.

Stars Badge Forks Badge Pull Requests Badge Issues Badge License Badge

v2 (Astro Γ— Bun) runs on karhdo.dev from main Β· v1 (Next.js) stays on v1.karhdo.dev from the v1 branch.


Karhdo's Blog

Tech stack

Astro 7 + Bun, TypeScript strict, Tailwind CSS v4 with Tokyonight Day / Night tokens, MDX with Expressive Code, Drizzle on Neon Postgres, Pagefind search, Satori OG images, Biome, deployed on Vercel (Functions on Node 24). Interactivity is vanilla <script> modules; React 19 is used only for Giscus comments and the ⌘K palette.

Features

  • Bento homepage: typed bios, latest post, now playing (Last.fm), GitHub activity heatmap, blog stats, Token burn (Claude Code usage), stack marquee, projects.
  • Blog with tags, RSS, ⌘K search, TOC scrollspy, code blocks with filename tabs, callouts, image zoom, views and reactions, Giscus comments and a newsletter.
  • /about terminal card, /career as a git log --graph, site-wide snowfall, light/dark/system theme and view transitions.

Quickstart

Requires Bun 1.3.14 and Node β‰₯ 22.12. Every env var is optional: without them each feature shows an empty state.

bun install                # also installs the lefthook pre-commit hook
cp .env.example .env.local
bun dev                    # http://localhost:4321 (plus dev-only /dev/* pages)
Command What it does
bun test Unit tests (*.test.ts next to the code)
bun run check astro check + biome check . (bun run check:fix to fix)
bun run lint:palette Fails on colour literals outside the Tokyonight token files
bun run build Production build into .vercel/output
bun run cv:build cv/resume.tex β†’ public/static/resume.pdf

Previewing a build

@astrojs/vercel doesn't support astro preview. Serve .vercel/output/static with a static server, use bunx vercel dev, or deploy a preview. On-demand routes (/api/*, /projects, /newsletter) need bun dev.

Project structure

β”œβ”€β”€ astro.config.mjs   # adapter, integrations, markdown pipeline, astro:env schema
β”œβ”€β”€ cv/                # resume source
β”œβ”€β”€ public/static/     # images, favicons, resume.pdf, Twemoji SVGs
β”œβ”€β”€ scripts/           # build info, palette lint, token-burn setup
└── src/
    β”œβ”€β”€ pages/         # routes (api/*, projects, newsletter are on-demand; the rest is prerendered)
    β”œβ”€β”€ components/    # grouped by feature
    β”œβ”€β”€ content/       # blog and author MDX
    β”œβ”€β”€ config/        # site data, navigation, projects, experiences
    β”œβ”€β”€ lib/           # pure, tested logic + thin services (db, stats, github, lastfm, token-burn, og)
    └── styles/        # theme.css (the only colour tokens), global, prose, animations

Environment variables

Declared in the astro:env schema in astro.config.mjs; see .env.example. The v1 names are kept so Vercel needs no renames.

Variable Used for
POSTGRES_URL Views, reactions, blog stats (Neon -pooler host)
GITHUB_API_TOKEN /projects, GitHub cards, footer stars
LASTFM_API_KEY, LASTFM_USERNAME Now playing
BUTTONDOWN_API_KEY Newsletter (read at build too: adding it needs a redeploy)
TOKEN_BURN_INGEST_KEY Token burn ingest (Production only)
NEXT_PUBLIC_GISCUS_* Giscus comments (repo, repository ID, category, category ID)
UMAMI_WEBSITE_ID Umami analytics

Token burn

Claude Code's OpenTelemetry export sends token and cost metrics to POST /api/otel/v1/metrics, stored per day and model in token_burn_daily. On each machine, run:

curl -fsSL https://raw.githubusercontent.com/Karhdo/karhdo.dev/main/scripts/setup-token-burn-telemetry.sh | bash

It asks for TOKEN_BURN_INGEST_KEY and merges the CLAUDE_CODE_ENABLE_TELEMETRY and OTEL_* settings (endpoint, Authorization=Bearer <key> header, delta temporality) into ~/.claude/settings.json.

Now playing

Spotify's Web API needs Premium, so the card reads Last.fm instead: connect Spotify Scrobbling in Last.fm settings (reconnect every 180 days), create an API account, then set LASTFM_API_KEY and LASTFM_USERNAME.

Deployment

  • v2: Vercel project karhdo-blog, deployed on every push (main β†’ production). Keep "Automatically expose System Environment Variables" on (the footer reads VERCEL_GIT_*).
  • v1: project karhdo-blog-v1, deployed by hand from a v1 checkout: vercel link --project karhdo-blog-v1 && vercel deploy --prod.

Credits

License

MIT © Do Trong Khanh (Karhdo). If this project helped you, a ⭐ is appreciated.

About

My 🏑 in the ☁: blog and portfolio of Trong Khanh (Karhdo). v2 on Astro Γ— Bun, Tailwind v4 and Tokyonight; v1 (Next.js) lives on the v1 branch.

Topics

Resources

Stars

80 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages