Skip to content

Commit 5801e77

Browse files
committed
feat: add badge collections documentation and update README navigation
1 parent 74b46b1 commit 5801e77

3 files changed

Lines changed: 178 additions & 1 deletion

File tree

docs/how-to/BADGE_COLLECTIONS.md

Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
# Badge Collections
2+
3+
This guide explains how to combine multiple user badges into a single SVG using the badge collection endpoint.
4+
5+
## Overview
6+
7+
Badge collections are useful when you want one compact image instead of many separate badge URLs.
8+
9+
Use cases:
10+
- GitHub profile README blocks
11+
- Documentation hero sections
12+
- Project landing pages
13+
- Release notes snapshots
14+
15+
---
16+
17+
## Endpoint
18+
19+
```http
20+
GET /badge/collection
21+
```
22+
23+
Base demo URL:
24+
25+
```text
26+
https://stats.pphat.top/badge/collection
27+
```
28+
29+
---
30+
31+
## Required Query Parameters
32+
33+
| Parameter | Type | Description |
34+
|---|---|---|
35+
| `username` | string | GitHub username |
36+
| `type` | string | Comma-separated user badge types |
37+
38+
Supported badge types:
39+
- `visitors`
40+
- `repositories`
41+
- `organization`
42+
- `languages`
43+
- `followers`
44+
- `total-stars`
45+
- `total-contributors`
46+
- `total-commits`
47+
- `total-code-reviews`
48+
- `total-issues`
49+
- `total-pull-requests`
50+
- `total-joined-years`
51+
52+
---
53+
54+
## Optional Query Parameters
55+
56+
| Parameter | Type | Default | Description |
57+
|---|---|---|---|
58+
| `columns` | integer | `50` | Grid column count (`1` to `50`) |
59+
| `gap` | integer | `5` | Space between badges in pixels (`0` to `100`) |
60+
| `theme` | string | `default` | Theme name |
61+
| `customLabel` | string | - | Override label text for all badges in the collection |
62+
| `labelColor` | string | - | Label text color |
63+
| `labelBackground` | string | - | Label background color |
64+
| `iconColor` | string | - | Icon color |
65+
| `valueColor` | string | - | Value text color |
66+
| `valueBackground` | string | - | Value background color |
67+
68+
---
69+
70+
## Basic Usage
71+
72+
### 1) Minimal request
73+
74+
```bash
75+
curl "https://stats.pphat.top/badge/collection?username=pphatdev&type=visitors,total-stars"
76+
```
77+
78+
Preview:
79+
80+
![badge-collection-basic](https://stats.pphat.top/badge/collection?username=pphatdev&type=visitors,total-stars)
81+
82+
### 2) Set explicit columns
83+
84+
```bash
85+
curl "https://stats.pphat.top/badge/collection?username=pphatdev&type=visitors,repositories,followers,total-stars&columns=2"
86+
```
87+
88+
Preview:
89+
90+
![badge-collection-columns](https://stats.pphat.top/badge/collection?username=pphatdev&type=visitors,repositories,followers,total-stars&columns=2)
91+
92+
### 3) Add spacing with gap
93+
94+
```bash
95+
curl "https://stats.pphat.top/badge/collection?username=pphatdev&type=visitors,repositories,followers,total-stars&columns=2&gap=12"
96+
```
97+
98+
Preview:
99+
100+
![badge-collection-gap](https://stats.pphat.top/badge/collection?username=pphatdev&type=visitors,repositories,followers,total-stars&columns=2&gap=12)
101+
102+
---
103+
104+
## Styling Examples
105+
106+
### Theme
107+
108+
![badge-collection-theme](https://stats.pphat.top/badge/collection?username=pphatdev&type=visitors,total-stars,repositories&theme=ocean)
109+
110+
### Custom colors
111+
112+
![badge-collection-colors](https://stats.pphat.top/badge/collection?username=pphatdev&type=visitors,total-stars,repositories&labelBackground=0d1117&labelColor=ffffff&valueBackground=1f2937&valueColor=22c55e)
113+
114+
### Custom label applied to all badges
115+
116+
![badge-collection-custom-label](https://stats.pphat.top/badge/collection?username=pphatdev&type=visitors,total-stars,repositories&customLabel=My%20Stats)
117+
118+
---
119+
120+
## Embedding
121+
122+
### Markdown
123+
124+
```markdown
125+
![My Badge Collection](https://stats.pphat.top/badge/collection?username=pphatdev&type=visitors,repositories,followers,total-stars&columns=2)
126+
```
127+
128+
### HTML
129+
130+
```html
131+
<img src="https://stats.pphat.top/badge/collection?username=pphatdev&type=visitors,repositories,followers,total-stars&columns=2" alt="My Badge Collection" />
132+
```
133+
134+
---
135+
136+
## Error Cases
137+
138+
### Missing `username`
139+
140+
```bash
141+
curl "https://stats.pphat.top/badge/collection?type=visitors,total-stars"
142+
```
143+
144+
### Missing `type`
145+
146+
```bash
147+
curl "https://stats.pphat.top/badge/collection?username=pphatdev"
148+
```
149+
150+
### Invalid `type`
151+
152+
```bash
153+
curl "https://stats.pphat.top/badge/collection?username=pphatdev&type=visitors,unknown"
154+
```
155+
156+
### Invalid `columns`
157+
158+
```bash
159+
curl "https://stats.pphat.top/badge/collection?username=pphatdev&type=visitors,total-stars&columns=0"
160+
```
161+
162+
### Invalid `gap`
163+
164+
```bash
165+
curl "https://stats.pphat.top/badge/collection?username=pphatdev&type=visitors,total-stars&gap=500"
166+
```
167+
168+
---
169+
170+
## Notes
171+
172+
- The `visitors` badge in collection mode is read-only and does not increment visitor count.
173+
- Collection responses are served as `image/svg+xml` with ETag and cache headers.
174+
- Badge IDs are scoped internally to prevent SVG filter/clip-path collisions.

docs/how-to/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ This folder contains comprehensive guides on how to use each API route available
1010
### 👤 User Badges
1111
- **[User Badge Routes](./USER_BADGES.md)** - Personal GitHub statistics badges (visitors, repos, followers, etc.)
1212

13+
### 🧩 Badge Collections
14+
- **[Badge Collections](./BADGE_COLLECTIONS.md)** - Compose multiple user badges into one SVG image
15+
1316
### 📁 Project Badges
1417
- **[Project Badge Routes](./PROJECT_BADGES.md)** - Repository-specific badges (stars, forks, issues, etc.)
1518

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "github-stats",
3-
"version": "2.0.1",
3+
"version": "2.0.2",
44
"description": "Generate dynamic GitHub stats cards for your README",
55
"main": "dist/index.js",
66
"type": "module",

0 commit comments

Comments
 (0)