-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gravatar.js
35 lines (32 loc) · 882 Bytes
/
gravatar.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import { md5 } from './hash.js';
import { createImage } from './elements.js';
export async function createGravatarURL(email, { size = 256 } = {}) {
const hash = await md5(email);
const url = new URL(hash, 'https://secure.gravatar.com/avatar/');
url.searchParams.set('s', size);
url.searchParams.set('d', 'mm');
return url;
}
export async function createGravatar(email, {
size = 256,
alt = '',
id,
classList = [],
part = [],
loading = 'lazy',
fetchPriority = 'auto',
decoding = 'async',
crossOrigin = 'anonymous',
referrerPolicy = 'no-referrer',
itemprop = null,
animation,
aria,
events,
dataset,
} = {}) {
const url = await createGravatarURL(email, { size });
return createImage(url, {
height: size, width: size, alt, classList, part, loading, fetchPriority, aria,
crossOrigin, referrerPolicy, decoding, itemprop, animation, events, dataset, id,
});
}