forked from Roshanjossey/devicon.dev
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path+page.server.ts
More file actions
35 lines (30 loc) · 842 Bytes
/
+page.server.ts
File metadata and controls
35 lines (30 loc) · 842 Bytes
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 type { IIcon } from "$lib/types/types"
export async function load() {
try {
const response = await fetch(
"https://raw.githubusercontent.com/devicons/devicon/master/devicon.json",
)
if (!response.ok) {
throw new Error(`Failed to fetch icons: ${response.statusText}`)
}
const icons: IIcon[] = await response.json()
// Extract all available tags
const availableTags = new Set()
icons.forEach((icon) => {
if (icon.tags && Array.isArray(icon.tags)) {
icon.tags.forEach((tag) => availableTags.add(tag))
}
})
return {
icons,
availableTags: Array.from(availableTags).sort(),
}
} catch (error: any) {
console.error("Error fetching icons:", error)
return {
icons: [],
availableTags: [],
error: error.message,
}
}
}