@unavatar/core 3.14.2 → 3.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -33,6 +33,7 @@
33
33
  - [Reddit](#reddit)
34
34
  - [SoundCloud](#soundcloud)
35
35
  - [Spotify](#spotify)
36
+ - [Steam](#steam)
36
37
  - [Substack](#substack)
37
38
  - [Telegram](#telegram)
38
39
  - [TikTok](#tiktok)
@@ -487,6 +488,22 @@ Available URI format inputs:
487
488
  - `track`: [unavatar.io/spotify/track:4OROzZUy6gOWN4UGQVaZMF](https://unavatar.io/spotify/track:4OROzZUy6gOWN4UGQVaZMF)
488
489
  - `user` (default): [unavatar.io/spotify/user:kikobeats](https://unavatar.io/spotify/user:kikobeats)
489
490
 
491
+ ### Steam
492
+
493
+ Get any Steam Community avatar by vanity ID, numeric profile ID, or group slug.
494
+
495
+ e.g., [unavatar.io/steam/Kikobeats](https://unavatar.io/steam/Kikobeats)
496
+
497
+ The input supports a URI format `type:id`.
498
+
499
+ When no type is provided, it defaults to `id` (vanity profile URL).
500
+
501
+ Available URI format inputs:
502
+
503
+ - `id` (default): [unavatar.io/steam/Kikobeats](https://unavatar.io/steam/Kikobeats)
504
+ - `profiles`: [unavatar.io/steam/profiles:76561197976050016](https://unavatar.io/steam/profiles:76561197976050016)
505
+ - `groups`: [unavatar.io/steam/groups:microlink](https://unavatar.io/steam/groups:microlink)
506
+
490
507
  ### Substack
491
508
 
492
509
  Get any Substack author's profile picture by their publication username.
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@unavatar/core",
3
3
  "description": "Get unified user avatar from social networks, including Instagram, SoundCloud, Telegram, Twitter, YouTube & more.",
4
4
  "homepage": "https://unavatar.io",
5
- "version": "3.14.2",
5
+ "version": "3.15.0",
6
6
  "main": "src/index.js",
7
7
  "exports": {
8
8
  ".": "./src/index.js",
@@ -25,6 +25,7 @@ const providersBy = {
25
25
  'snapchat',
26
26
  'soundcloud',
27
27
  'spotify',
28
+ 'steam',
28
29
  'substack',
29
30
  'telegram',
30
31
  'threads',
@@ -65,6 +66,7 @@ module.exports = ctx => {
65
66
  snapchat: require('./snapchat')(ctx),
66
67
  soundcloud: require('./soundcloud')(ctx),
67
68
  spotify: require('./spotify')(ctx),
69
+ steam: require('./steam')(ctx),
68
70
  substack: require('./substack')(ctx),
69
71
  telegram: require('./telegram')(ctx),
70
72
  threads: require('./threads')(ctx),
@@ -0,0 +1,29 @@
1
+ 'use strict'
2
+
3
+ const getAvatarUrl = input => {
4
+ const [first, second] = input.split(':')
5
+ const type = second ? first : 'id'
6
+ const id = encodeURIComponent(second ?? first)
7
+
8
+ switch (type) {
9
+ case 'id':
10
+ return `https://steamcommunity.com/id/${id}`
11
+ case 'profile':
12
+ case 'profiles':
13
+ return `https://steamcommunity.com/profiles/${id}`
14
+ case 'group':
15
+ case 'groups':
16
+ return `https://steamcommunity.com/groups/${id}`
17
+ default:
18
+ throw new Error(`Unsupported Steam type: ${type}`)
19
+ }
20
+ }
21
+
22
+ module.exports = ({ createHtmlProvider, getOgImage }) =>
23
+ createHtmlProvider({
24
+ name: 'steam',
25
+ url: getAvatarUrl,
26
+ getter: getOgImage
27
+ })
28
+
29
+ module.exports.getAvatarUrl = getAvatarUrl