diff --git a/app/api/wakatime-stats/route.ts b/app/api/wakatime-stats/route.ts new file mode 100644 index 0000000..a19505f --- /dev/null +++ b/app/api/wakatime-stats/route.ts @@ -0,0 +1,50 @@ +import { NextRequest } from 'next/server' + +type Language = { + name: string + hours: string +} + +export async function GET(request: NextRequest) { + const url = request.nextUrl + const username = url.searchParams.get('username') + + if (!username) { + return new Response(JSON.stringify({ error: 'Username is required' }), { + status: 400, + headers: { + 'Content-Type': 'application/json', + }, + }) + } + + try { + const response = await fetch(`https://wakatime.com/api/v1/users/${username}/stats/all_time`) + + if (!response.ok) { + console.log(response.status) + throw new Error('Failed to fetch data from WakaTime API') + } + + const data = await response.json() + const topLanguages: Language[] = data.data.languages.map((lang: any) => ({ + name: lang.name, + hours: (lang.total_seconds / 3600).toFixed(2), + })) + + return new Response(JSON.stringify(topLanguages), { + status: 200, + headers: { + 'Content-Type': 'application/json', + }, + }) + } catch (error) { + console.error('WakaTime API error:', error) + return new Response(JSON.stringify({ error: 'Internal server error' }), { + status: 500, + headers: { + 'Content-Type': 'application/json', + }, + }) + } +} diff --git a/app/globals.css b/app/globals.css index e18918f..ac03b59 100644 --- a/app/globals.css +++ b/app/globals.css @@ -36,6 +36,14 @@ --ring: 34 54% 45%; --radius: 0.5rem; + + --chart-1: 34 54% 81%; + --chart-2: 34 34% 73%; + --chart-3: 35 22% 65%; + --chart-4: 35 16% 57%; + --chart-5: 35 12% 41%; + --chart-6: 33 12% 33%; + --chart-7: 32 12% 25%; } .dark { @@ -71,6 +79,14 @@ --ring: 34 54% 81%; --radius: 0.5rem; + + --chart-1: 34 54% 81%; + --chart-2: 34 34% 73%; + --chart-3: 35 22% 65%; + --chart-4: 35 16% 57%; + --chart-5: 35 12% 41%; + --chart-6: 33 12% 33%; + --chart-7: 32 12% 25%; } * { @@ -241,10 +257,6 @@ background-image: url('/static/images/bento/github.webp'); } - .grid-item-j { - background-image: url('/static/images/bento/technologies.webp'); - } - .grid-item-k-overlay { background-image: url('/static/images/bento/twitter.webp'); } diff --git a/components/bento/BentoBox.tsx b/components/bento/BentoBox.tsx index c7dffd1..e7c6f24 100644 --- a/components/bento/BentoBox.tsx +++ b/components/bento/BentoBox.tsx @@ -10,6 +10,7 @@ import ExternalLink from './ExternalLink' import GithubCalendar from './GithubCalendar' import SpotifyPresence from './SpotifyPresence' import { Skeleton } from '../shadcn/skeleton' +import WakatimeGraph from './WakatimeGraph' const BentoBox = ({ posts }) => { const lanyard = useLanyard({ @@ -105,11 +106,13 @@ const BentoBox = ({ posts }) => { /> -