Skip to content

Commit b7df26c

Browse files
committed
Add badge collection feature with documentation and routes
- Implement BadgeCollectionController to render multiple badges as a single SVG. - Create routes for badge collection and integrate with existing route registration. - Update API documentation for badge collection endpoint. - Add examples and error handling for badge collection requests. - Bump version to 2.0.1 in package.json.
1 parent 6fcf4c7 commit b7df26c

8 files changed

Lines changed: 603 additions & 3 deletions

File tree

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Icons enhance release documentation by:
2020
- [Technology Stack Display](#technology-stack-display)
2121
- [Themed Icon Sets](#themed-icon-sets)
2222
- [Best Practices](#best-practices)
23+
- [Current Release (v2.0.1)](#current-release-v201)
2324

2425
---
2526

@@ -297,6 +298,51 @@ Icons are SVGs served directly from the server. They're lightweight and render q
297298

298299
---
299300

301+
## Current Release (v2.0.1)
302+
303+
Use this section as a copy-ready template for the current release.
304+
305+
### Highlights
306+
307+
- Added `GET /badge/collection` to render multiple user badges into one SVG.
308+
- Added collection layout controls: `columns` and `gap`.
309+
- Added endpoint examples and documentation for badge collection in `docs/example/badge-collection.md`.
310+
- Fixed collection SVG composition to avoid duplicate `width`/`height` attributes.
311+
312+
### Release Notes Template
313+
314+
```markdown
315+
# Release v2.0.1
316+
317+
![TypeScript](https://stats.pphat.top/icons/typescript?color=%233178C6) ![Node.js](https://stats.pphat.top/icons/nodedotjs?color=%23339933) ![GitHub](https://stats.pphat.top/icons/github?color=white)
318+
319+
## Added
320+
- `GET /badge/collection` endpoint for multi-badge SVG output.
321+
- New docs: `docs/example/badge-collection.md`.
322+
323+
## Improved
324+
- Better layout customization for badge collections using `columns` and `gap`.
325+
326+
## Fixed
327+
- XML parsing issue in composed badge SVGs caused by duplicate attributes.
328+
329+
## Quick Demo
330+
![badge-collection](https://stats.pphat.top/badge/collection?username=pphatdev&type=visitors,total-stars,repositories&columns=3)
331+
```
332+
333+
### Release Badge Examples (v2.0.1)
334+
335+
```markdown
336+
![version](https://img.shields.io/badge/version-2.0.1-22c55e)
337+
![badge-collection-demo](https://stats.pphat.top/badge/collection?username=pphatdev&type=visitors,total-stars,repositories,followers&columns=2&gap=10)
338+
```
339+
340+
Preview:
341+
342+
![badge-collection-demo](https://stats.pphat.top/badge/collection?username=pphatdev&type=visitors,total-stars,repositories,followers&columns=2&gap=10)
343+
344+
---
345+
300346
## Advanced Examples
301347

302348
### Changelog with Icons

docs/example/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@ This folder contains one file per route, with demo examples for each available o
1010
- [GET /icons and /icons/:name](./icons.md)
1111
- [GET /icons (Collection Mode)](./icon-collection.md)
1212
- [GET /badge/:type](./badge-user.md)
13+
- [GET /badge/collection](./badge-collection.md)
1314
- [GET /project/:type](./project.md)
1415

1516
## Additional Guides
1617

17-
- [Release Icons Documentation](../how-to/RELEASE_ICONS.md) - How to use icons in releases, changelogs, and READMEs
18+
- [Release Icons Documentation](../RELEASE/RELEASE_ICONS.md) - How to use icons in releases, changelogs, and READMEs
1819

1920
## Notes
2021

docs/example/badge-collection.md

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
# GET /badge/collection
2+
3+
Render multiple user badges into one SVG image.
4+
5+
## Route
6+
7+
- /badge/collection?username=pphatdev&type=visitors,total-stars,repositories
8+
9+
## Required Query Params
10+
11+
| Param | Description |
12+
|---|---|
13+
| username | GitHub username |
14+
| type | Comma-separated user badge types |
15+
16+
Supported badge types:
17+
18+
- visitors
19+
- repositories
20+
- organization
21+
- languages
22+
- followers
23+
- total-stars
24+
- total-contributors
25+
- total-commits
26+
- total-code-reviews
27+
- total-issues
28+
- total-pull-requests
29+
- total-joined-years
30+
31+
## Optional Query Params
32+
33+
| Param | Description |
34+
|---|---|
35+
| columns | Number of columns in the grid (default: 1, max: 10) |
36+
| gap | Gap between badges in pixels (default: 8, range: 0-100) |
37+
| theme | Badge theme |
38+
| customLabel | Custom label text (applies to all badges in the collection) |
39+
| labelColor | Label text color |
40+
| labelBackground | Label background color |
41+
| iconColor | Icon color |
42+
| valueColor | Value text color |
43+
| valueBackground | Value background color |
44+
45+
## Basic Examples
46+
47+
Two badges in one SVG:
48+
49+
![badge-collection-basic](https://stats.pphat.top/badge/collection?username=pphatdev&type=visitors,total-stars)
50+
51+
Multiple badges with 3 columns:
52+
53+
![badge-collection-columns](https://stats.pphat.top/badge/collection?username=pphatdev&type=visitors,repositories,followers,total-stars,total-issues,total-pull-requests&columns=3)
54+
55+
## Layout Examples
56+
57+
Custom columns and gap:
58+
59+
![badge-collection-layout](https://stats.pphat.top/badge/collection?username=pphatdev&type=visitors,repositories,followers,total-stars,total-issues,total-pull-requests&columns=2&gap=12)
60+
61+
Single-row layout:
62+
63+
![badge-collection-row](https://stats.pphat.top/badge/collection?username=pphatdev&type=visitors,repositories,followers,total-stars,total-issues,total-pull-requests&columns=6)
64+
65+
## Style Examples
66+
67+
Theme:
68+
69+
![badge-collection-theme](https://stats.pphat.top/badge/collection?username=pphatdev&type=visitors,total-stars,repositories&theme=ocean)
70+
71+
Custom colors:
72+
73+
![badge-collection-colors](https://stats.pphat.top/badge/collection?username=pphatdev&type=visitors,total-stars,repositories&labelBackground=0d1117&labelColor=ffffff&valueBackground=1f2937&valueColor=22c55e)
74+
75+
## Combined Example
76+
77+
Theme + colors + columns + gap:
78+
79+
![badge-collection-combined](https://stats.pphat.top/badge/collection?username=pphatdev&type=visitors,repositories,followers,total-stars,total-issues,total-pull-requests&theme=tokyonight&columns=3&gap=10&labelBackground=0d1117&valueBackground=111827)
80+
81+
## Curl Examples
82+
83+
```bash
84+
curl "https://stats.pphat.top/badge/collection?username=pphatdev&type=visitors,total-stars"
85+
curl "https://stats.pphat.top/badge/collection?username=pphatdev&type=visitors,repositories,followers,total-stars&columns=2"
86+
curl "https://stats.pphat.top/badge/collection?username=pphatdev&type=visitors,total-stars,repositories&theme=ocean"
87+
```
88+
89+
## Error Examples
90+
91+
Missing username:
92+
93+
```bash
94+
curl "https://stats.pphat.top/badge/collection?type=visitors,total-stars"
95+
```
96+
97+
Missing type:
98+
99+
```bash
100+
curl "https://stats.pphat.top/badge/collection?username=pphatdev"
101+
```
102+
103+
Invalid type:
104+
105+
```bash
106+
curl "https://stats.pphat.top/badge/collection?username=pphatdev&type=visitors,unknown-badge"
107+
```
108+
109+
Invalid columns:
110+
111+
```bash
112+
curl "https://stats.pphat.top/badge/collection?username=pphatdev&type=visitors,total-stars&columns=0"
113+
```

docs/how-to/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ This folder contains comprehensive guides on how to use each API route available
1414
- **[Project Badge Routes](./PROJECT_BADGES.md)** - Repository-specific badges (stars, forks, issues, etc.)
1515

1616
### 🎨 Icons & Visual Assets
17-
- **[Release Icons Documentation](./RELEASE_ICONS.md)** - Using icons in releases, changelogs, and READMEs
17+
- **[Release Icons Documentation](../RELEASE/RELEASE_ICONS.md)** - Using icons in releases, changelogs, and READMEs
1818

1919
### 🔧 Monitoring & Health
2020
- **[Cache Monitoring Guide](./CACHE_MONITORING.md)** - Health checks and cache statistics endpoints

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.0",
3+
"version": "2.0.1",
44
"description": "Generate dynamic GitHub stats cards for your README",
55
"main": "dist/index.js",
66
"type": "module",

0 commit comments

Comments
 (0)