Compare commits

..

3 commits

Author SHA1 Message Date
Markus Thielker
5b46d0ce1e Update dependencies 2025-02-27 21:52:46 +01:00
Markus Thielker
332cc5ddde Fix code format 2025-02-26 14:20:38 +01:00
Markus Thielker
a3e2f442a0 Fix caching to prevent build-time rendering 2025-02-26 14:20:05 +01:00
3 changed files with 22 additions and 20 deletions

BIN
bun.lockb

Binary file not shown.

View file

@ -9,27 +9,27 @@
"lint": "next lint" "lint": "next lint"
}, },
"dependencies": { "dependencies": {
"@radix-ui/react-separator": "^1.1.1", "@radix-ui/react-separator": "^1.1.2",
"@radix-ui/react-slot": "^1.1.1", "@radix-ui/react-slot": "^1.1.2",
"@radix-ui/react-tabs": "^1.1.2", "@radix-ui/react-tabs": "^1.1.3",
"class-variance-authority": "^0.7.1", "class-variance-authority": "^0.7.1",
"clsx": "^2.1.1", "clsx": "^2.1.1",
"lucide-react": "^0.468.0", "lucide-react": "^0.468.0",
"next": "15.1.0", "next": "15.1.0",
"react": "^19.0.0", "react": "^19.0.0",
"react-dom": "^19.0.0", "react-dom": "^19.0.0",
"tailwind-merge": "^2.5.5", "tailwind-merge": "^2.6.0",
"tailwindcss-animate": "^1.0.7" "tailwindcss-animate": "^1.0.7"
}, },
"devDependencies": { "devDependencies": {
"typescript": "^5", "typescript": "^5.7.3",
"@types/node": "^20", "@types/node": "^20.17.19",
"@types/react": "^19", "@types/react": "^19.0.10",
"@types/react-dom": "^19", "@types/react-dom": "^19.0.4",
"postcss": "^8", "postcss": "^8.5.3",
"tailwindcss": "^3.4.1", "tailwindcss": "^3.4.17",
"eslint": "^9", "eslint": "^9.21.0",
"eslint-config-next": "15.1.0", "eslint-config-next": "15.1.0",
"@eslint/eslintrc": "^3" "@eslint/eslintrc": "^3.3.0"
} }
} }

View file

@ -21,7 +21,7 @@ const calculateAge = (birthdate: Date): number => {
return age; return age;
}; };
const getRepos = async (username: string) => { const getRepos = async (username: string, options: RequestInit = {}) => {
let repos: Repository[] = []; let repos: Repository[] = [];
let page = 1; let page = 1;
let hasNextPage = true; let hasNextPage = true;
@ -31,6 +31,7 @@ const getRepos = async (username: string) => {
headers: { headers: {
Accept: 'application/vnd.github+json', Accept: 'application/vnd.github+json',
}, },
...options,
}); });
const data = await response.json(); const data = await response.json();
@ -46,11 +47,12 @@ const getRepos = async (username: string) => {
return repos; return repos;
}; };
const getLanguages = async (repo: Repository) => { const getLanguages = async (repo: Repository, options: RequestInit = {}) => {
const response = await fetch(repo.languages_url, { const response = await fetch(repo.languages_url, {
headers: { headers: {
Accept: 'application/vnd.github+json', Accept: 'application/vnd.github+json',
}, },
...options,
}); });
return await response.json(); return await response.json();
}; };
@ -59,7 +61,7 @@ const accumulateLanguages = async (repos: Repository[]) => {
const languages: { [key: string]: number } = {}; const languages: { [key: string]: number } = {};
for (const repo of repos) { for (const repo of repos) {
const repoLanguages = await getLanguages(repo); const repoLanguages = await getLanguages(repo, { next: { revalidate: 3600 } });
for (const lang in repoLanguages) { for (const lang in repoLanguages) {
languages[lang] = (languages[lang] || 0) + repoLanguages[lang]; languages[lang] = (languages[lang] || 0) + repoLanguages[lang];
} }
@ -80,11 +82,11 @@ const accumulateStars = (repos: Repository[]) => {
export default async function Home() { export default async function Home() {
const profileResponse = await fetch('https://api.github.com/users/markusthielker'); const profileResponse = await fetch('https://api.github.com/users/markusthielker', { next: { revalidate: 3600 } });
const profile = await profileResponse.json() as PublicUser; const profile = await profileResponse.json() as PublicUser;
const username = 'markusthielker'; const username = 'markusthielker';
const repos = await getRepos(username); const repos = await getRepos(username, { next: { revalidate: 3600 } });
const languages = await accumulateLanguages(repos); const languages = await accumulateLanguages(repos);
const stars = accumulateStars(repos); const stars = accumulateStars(repos);
const totalBytes = Object.values(languages).reduce((sum, bytes) => sum + bytes, 0); const totalBytes = Object.values(languages).reduce((sum, bytes) => sum + bytes, 0);
@ -98,7 +100,7 @@ export default async function Home() {
.slice(0, 3); .slice(0, 3);
const age = calculateAge(new Date('2001-03-04')); const age = calculateAge(new Date('2001-03-04'));
const year = new Date().getFullYear() const year = new Date().getFullYear();
return ( return (
<div className="flex flex-col min-h-screen"> <div className="flex flex-col min-h-screen">
@ -162,7 +164,8 @@ export default async function Home() {
<section className="grid gap-4 grid-cols-2 sm:grid-cols-4 md:grid-cols-8"> <section className="grid gap-4 grid-cols-2 sm:grid-cols-4 md:grid-cols-8">
{ /* images */} { /* images */}
<Card className="col-span-2 sm:col-span-4 md:row-span-2 overflow-hidden sm:grid sm:gap-0.5 sm:grid-cols-2 lg:grid-cols-5 sm:grid-row-2 md:max-h-72"> <Card
className="col-span-2 sm:col-span-4 md:row-span-2 overflow-hidden sm:grid sm:gap-0.5 sm:grid-cols-2 lg:grid-cols-5 sm:grid-row-2 md:max-h-72">
<div className="flex sm:col-span-1 lg:col-span-3 lg:row-span-2 max-h-72"> <div className="flex sm:col-span-1 lg:col-span-3 lg:row-span-2 max-h-72">
<Image <Image
height="500" height="500"
@ -252,7 +255,6 @@ export default async function Home() {
</CardContent> </CardContent>
</Card> </Card>
{ /* TODO */}
<Card className="hidden sm:block sm:col-span-2 md:hidden lg:block"> <Card className="hidden sm:block sm:col-span-2 md:hidden lg:block">
<CardHeader> <CardHeader>
<CardDescription> <CardDescription>