I built this little tool to generate a dynamic SVG badge of my Dreamhack stats (Level, CTF Tier, Wargame Points, etc.) so I could display it on my GitHub profile.
It runs on Vercel Edge Functions and uses next/og to style the badge. Since Dreamhack doesn't have a public API for these specific stats, this script fetches my public profile page and extracts the data directly from the HTML.
You need to point this to your own profile.
- Go to your Dreamhack profile page and check the URL.
- Example: https://dreamhack.io/users/12345/ -> 12345 is your ID.
-
Open
app/api/badge/route.jsx. -
Change the
userIdvariable at the top of the function:
export async function GET(req) {
const userId = "YOUR_ID_HERE"; // <--- Put your ID here
const targetUrl = `https://dreamhack.io/users/${userId}/`;
// ...
}The easiest way to host this is on Vercel.
- Push this code to a GitHub repository.
- Go to Vercel and create a new project from that repo.
- It should auto-detect it's a Next.js app. Just hit deploy.
Once it's deployed, you can use the link in your GitHub README.md or any HTML page.
Markdown:
HTML:
<img
src="https://your-project-name.vercel.app/api/my-badge"
alt="Dreamhack Stats"
/>If you want to tweak the design locally:
npm install
npm run devThen visit http://localhost:3000/api/my-badge.
