init
This commit is contained in:
33
lib/data-loader.ts
Normal file
33
lib/data-loader.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import { SkillCategory, Team } from "./types";
|
||||
|
||||
export async function loadSkillCategories(): Promise<SkillCategory[]> {
|
||||
const categories = ["frontend", "backend", "devops", "mobile"];
|
||||
const skillCategories: SkillCategory[] = [];
|
||||
|
||||
for (const category of categories) {
|
||||
try {
|
||||
const response = await fetch(`/data/skills/${category}.json`);
|
||||
if (response.ok) {
|
||||
const data = await response.json();
|
||||
skillCategories.push(data);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`Failed to load ${category} skills:`, error);
|
||||
}
|
||||
}
|
||||
|
||||
return skillCategories;
|
||||
}
|
||||
|
||||
export async function loadTeams(): Promise<Team[]> {
|
||||
try {
|
||||
const response = await fetch("/data/teams.json");
|
||||
if (response.ok) {
|
||||
const data = await response.json();
|
||||
return data.teams;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Failed to load teams:", error);
|
||||
}
|
||||
return [];
|
||||
}
|
||||
Reference in New Issue
Block a user