feat: integrate Avatar component across various modules for improved user representation and enhance profile page with Gravatar support

This commit is contained in:
Julien Froidefond
2025-11-28 10:52:48 +01:00
parent cb4873cd40
commit ff7c846ed1
9 changed files with 108 additions and 27 deletions

23
src/lib/gravatar.ts Normal file
View File

@@ -0,0 +1,23 @@
import { createHash } from 'crypto';
export type GravatarDefault =
| 'identicon' // Geometric pattern
| 'mp' // Mystery person silhouette
| 'retro' // 8-bit pixel art
| 'robohash' // Generated robot
| 'wavatar' // Stylized face
| 'monsterid' // Colorful monster
| 'blank'; // Transparent
export function getGravatarUrl(
email: string,
size: number = 40,
fallback: GravatarDefault = 'identicon'
): string {
const hash = createHash('md5')
.update(email.toLowerCase().trim())
.digest('hex');
return `https://www.gravatar.com/avatar/${hash}?d=${fallback}&s=${size}`;
}