-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuseAboutData.js
More file actions
64 lines (56 loc) · 1.64 KB
/
useAboutData.js
File metadata and controls
64 lines (56 loc) · 1.64 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
import { useMemo } from 'react';
import { useSiteConfig } from '../context/SiteConfigContext';
import { aboutData as staticAboutData } from '../pages/about-views/aboutData';
import {
GithubLogoIcon,
LinkedinLogoIcon,
EnvelopeIcon,
XLogoIcon,
GlobeIcon,
RedditLogoIcon,
GitBranchIcon,
EnvelopeSimpleIcon,
} from '@phosphor-icons/react';
const ICON_MAP = {
GithubLogo: GithubLogoIcon,
LinkedinLogo: LinkedinLogoIcon,
EnvelopeSimple: EnvelopeSimpleIcon,
Envelope: EnvelopeIcon,
XLogo: XLogoIcon,
Globe: GlobeIcon,
RedditLogo: RedditLogoIcon,
GitBranch: GitBranchIcon,
};
export const useAboutData = () => {
const { config } = useSiteConfig();
const data = useMemo(() => {
if (!config || !config.socials) return staticAboutData;
const socialLinks = config.socials.map((link) => {
let label =
link.label.charAt(0).toUpperCase() + link.label.slice(1).toLowerCase();
// Custom label overrides to match original style if needed
if (link.id === 'twitter') label = 'X (Twitter)';
if (link.id === 'github') label = 'GitHub';
if (link.id === 'linkedin') label = 'LinkedIn';
if (link.id === 'website') label = 'Fezcode';
return {
id: link.id,
label: label,
url: link.url,
icon: ICON_MAP[link.icon] || GlobeIcon,
};
});
return {
...staticAboutData,
profile: {
...staticAboutData.profile,
email:
config.socials
.find((s) => s.id === 'email')
?.url.replace('mailto:', '') || staticAboutData.profile.email,
links: socialLinks,
},
};
}, [config]);
return data;
};