Skip to content

feat: About Section #77

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/Components/About/About.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,16 @@ const About: React.FC = () => {
</p>
</div>

<div className="AboutImageContainer">
<img
className="AboutImage"
src={`${process.env.PUBLIC_URL}/carson.webp`}
alt="PlaceHolder"
/>
</div>
</div>
{/*<div className="AboutImageContainer">
<img
className="AboutImage"
src={`${process.env.PUBLIC_URL}/carson.webp`}
alt="Carson"
/>
</div>*/}
</div>
</div>
);
};

export default About;
export default About;
32 changes: 32 additions & 0 deletions src/Components/Data/getGitHubStats.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// https://api.github.com/users/carsonSgit

import { TopLanguage, LanguageData } from '../Interfaces/githubStats';

export const getGitHubProfileStats = async () => {
const response = await fetch('https://api.github.com/users/carsonSgit');
const data = await response.json();
return data;
}

export const getGitHubProfileLanguages = async (): Promise<TopLanguage[]> => {
const reposResponse = await fetch('https://api.github.com/users/carsonSgit/repos');
const reposData = await reposResponse.json();

const languageMap: Record<string, number> = {};

for (const repo of reposData) {
const languagesResponse = await fetch(`https://api.github.com/repos/carsonSgit/${repo.name}/languages`);
const languagesData: LanguageData = await languagesResponse.json();

for (const [language, bytes] of Object.entries(languagesData)) {
if (language !== 'Jupyter Notebook' && language !== 'HTML' && language !== 'CSS' && language !== 'Mermaid' && language !== 'SCSS') {
languageMap[language] = (languageMap[language] || 0) + bytes;
}
}
}

return Object.entries(languageMap)
.sort(([, a], [, b]) => b - a)
.slice(0, 5)
.map(([language, bytes]) => ({ language, bytes }));
};
15 changes: 15 additions & 0 deletions src/Components/Interfaces/githubStats.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export interface GitHubStats {
login: string;
public_repos: number;
followers: number;
following: number;
}

export interface LanguageData {
[key: string]: number;
}

export interface TopLanguage {
language: string;
bytes: number;
}