Skip to content

Commit

Permalink
Converting paths
Browse files Browse the repository at this point in the history
  • Loading branch information
clintandrewhall committed Sep 12, 2024
1 parent baa9e21 commit c1584c6
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 2 deletions.
36 changes: 36 additions & 0 deletions src/components/github/loc.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { Language } from './loc_language';

export type Props = {
loc: LinesOfCode[] | null;
};

export const LOC = ({ loc }: Props) => {
if (!loc) {
return null;
}

const overallTotal = loc.reduce((acc, item) => acc + item.totalLines, 0);

const items = loc
.filter((item) => (item.totalLines / overallTotal) * 100 > 1)
.map((loc) => <Language {...{ loc, overallTotal }} />);

const otherTotal = loc
.filter((item) => (item.totalLines / overallTotal) * 100 <= 1)
.reduce((acc, item) => acc + item.totalLines, 0);

if (otherTotal > 0) {
items.push(
<Language
loc={{ languageName: 'Other', totalLines: otherTotal, byProject: {} }}
overallTotal={overallTotal}
/>,
);
}

if (items.length > 0) {
return <>{items}</>;
}

return null;
};
17 changes: 17 additions & 0 deletions src/components/github/stats.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { loc, user } from '@/content/github.json';

import { LOC } from './loc';
import { Numbers } from './numbers';

export const GithubStats = () => (
<>
<Numbers
{...user}
{...{
gists: user.public_gists,
repos: user.public_repos,
}}
/>
<LOC loc={loc} />
</>
);
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"baseUrl": ".",
"paths": {
"@/*": [
"src/*"
"./src/*"
]
}
},
Expand Down
2 changes: 1 addition & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export default defineConfig({
],
resolve: {
alias: {
'@': resolve(__dirname, './src'),
'@/': `${resolve('src')}/`,
},
},
});

0 comments on commit c1584c6

Please sign in to comment.