Compare commits

...
Sign in to create a new pull request.

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"
},
"dependencies": {
"@radix-ui/react-separator": "^1.1.1",
"@radix-ui/react-slot": "^1.1.1",
"@radix-ui/react-tabs": "^1.1.2",
"@radix-ui/react-separator": "^1.1.2",
"@radix-ui/react-slot": "^1.1.2",
"@radix-ui/react-tabs": "^1.1.3",
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
"lucide-react": "^0.468.0",
"next": "15.1.0",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"tailwind-merge": "^2.5.5",
"tailwind-merge": "^2.6.0",
"tailwindcss-animate": "^1.0.7"
},
"devDependencies": {
"typescript": "^5",
"@types/node": "^20",
"@types/react": "^19",
"@types/react-dom": "^19",
"postcss": "^8",
"tailwindcss": "^3.4.1",
"eslint": "^9",
"typescript": "^5.7.3",
"@types/node": "^20.17.19",
"@types/react": "^19.0.10",
"@types/react-dom": "^19.0.4",
"postcss": "^8.5.3",
"tailwindcss": "^3.4.17",
"eslint": "^9.21.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;
};
const getRepos = async (username: string) => {
const getRepos = async (username: string, options: RequestInit = {}) => {
let repos: Repository[] = [];
let page = 1;
let hasNextPage = true;
@ -31,6 +31,7 @@ const getRepos = async (username: string) => {
headers: {
Accept: 'application/vnd.github+json',
},
...options,
});
const data = await response.json();
@ -46,11 +47,12 @@ const getRepos = async (username: string) => {
return repos;
};
const getLanguages = async (repo: Repository) => {
const getLanguages = async (repo: Repository, options: RequestInit = {}) => {
const response = await fetch(repo.languages_url, {
headers: {
Accept: 'application/vnd.github+json',
},
...options,
});
return await response.json();
};
@ -59,7 +61,7 @@ const accumulateLanguages = async (repos: Repository[]) => {
const languages: { [key: string]: number } = {};
for (const repo of repos) {
const repoLanguages = await getLanguages(repo);
const repoLanguages = await getLanguages(repo, { next: { revalidate: 3600 } });
for (const lang in repoLanguages) {
languages[lang] = (languages[lang] || 0) + repoLanguages[lang];
}
@ -80,11 +82,11 @@ const accumulateStars = (repos: Repository[]) => {
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 username = 'markusthielker';
const repos = await getRepos(username);
const repos = await getRepos(username, { next: { revalidate: 3600 } });
const languages = await accumulateLanguages(repos);
const stars = accumulateStars(repos);
const totalBytes = Object.values(languages).reduce((sum, bytes) => sum + bytes, 0);
@ -98,7 +100,7 @@ export default async function Home() {
.slice(0, 3);
const age = calculateAge(new Date('2001-03-04'));
const year = new Date().getFullYear()
const year = new Date().getFullYear();
return (
<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">
{ /* 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">
<Image
height="500"
@ -252,7 +255,6 @@ export default async function Home() {
</CardContent>
</Card>
{ /* TODO */}
<Card className="hidden sm:block sm:col-span-2 md:hidden lg:block">
<CardHeader>
<CardDescription>