-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.ts
More file actions
68 lines (58 loc) · 2.01 KB
/
Copy pathindex.ts
File metadata and controls
68 lines (58 loc) · 2.01 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import { blogPosts } from "@/data/blog";
import { certificates } from "@/data/certificates";
import { experience } from "@/data/experience";
import { navSections } from "@/data/navigation";
import { profile } from "@/data/profile";
import { projects } from "@/data/projects";
import type {
BlogPost,
Certificate,
Experience,
NavSection,
Profile,
Project,
} from "@/lib/types";
/**
* Data access layer — the ONLY sanctioned way to read /data.
* Components import from here, never from /data directly, so the static
* files can be swapped for a CMS or database later without touching a
* single component. Shape correctness is enforced at compile time
* (`satisfies` in /data) and at test time (Zod, lib/data/data.test.ts).
*/
export function getProfile(): Profile {
return profile;
}
/** In-page sections in scroll order — see data/navigation.ts for the anchor id contract. */
export function getNavSections(): NavSection[] {
return [...navSections];
}
export function getProjects(): Project[] {
return [...projects];
}
/** Projects surfaced on the Home page highlight section. */
export function getFeaturedProjects(): Project[] {
return projects.filter((p) => p.featured);
}
export function getProjectBySlug(slug: string): Project | undefined {
return projects.find((p) => p.slug === slug);
}
/** Newest first. */
export function getCertificates(): Certificate[] {
return [...certificates].sort((a, b) => b.date.localeCompare(a.date));
}
/** Current position first, then by most recent start date. */
export function getExperience(): Experience[] {
return [...experience].sort((a, b) => {
if ((a.endDate === null) !== (b.endDate === null)) {
return a.endDate === null ? -1 : 1;
}
return b.startDate.localeCompare(a.startDate);
});
}
/** Newest first. */
export function getBlogPosts(): BlogPost[] {
return [...blogPosts].sort((a, b) => b.date.localeCompare(a.date));
}
export function getBlogPostBySlug(slug: string): BlogPost | undefined {
return blogPosts.find((p) => p.slug === slug);
}