forked from Roshanjossey/devicon.dev
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path+page.server.js
More file actions
31 lines (27 loc) · 846 Bytes
/
+page.server.js
File metadata and controls
31 lines (27 loc) · 846 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
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 = 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) {
console.error('Error fetching icons:', error);
return {
icons: [],
availableTags: [],
error: error.message
};
}
}