Skip to content
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
29 changes: 1 addition & 28 deletions src/app/[locale]/leaderboard/[country]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,40 +1,13 @@
import type { Metadata } from "next";
import countriesData from "@/data/countries.json";
import { JsonLd } from "@/components/seo/json-ld";
import { CountryLeaderboardClient } from "@/features/leaderboard";
import { getLeaderboardResult } from "@/features/leaderboard/services";
import { getLeaderboardResult, getCountryInfo } from "@/features/leaderboard/services";
import { toAbsoluteUrl } from "@/lib/seo";

type CountryInfo = {
slug: string;
title: string;
keywords?: string[];
};

type Props = {
params: Promise<{ locale?: string; country: string }>;
};

const countries = countriesData as CountryInfo[];

function formatCountryTitle(country: string): string {
return country
.split("_")
.filter(Boolean)
.map((segment) => segment.charAt(0).toUpperCase() + segment.slice(1))
.join(" ");
}

function getCountryInfo(country: string): CountryInfo {
return (
countries.find((entry) => entry.slug === country) ?? {
slug: country,
title: formatCountryTitle(country),
keywords: [],
}
);
}

export async function generateMetadata({ params }: Props): Promise<Metadata> {
const { country } = await params;
const countryInfo = getCountryInfo(country);
Expand Down
51 changes: 1 addition & 50 deletions src/app/[locale]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type { Metadata } from "next";
import { Suspense } from "react";
import { HomePageClient } from "@/features/comparison";
import { Skeleton } from "@/components/ui/skeleton";
import { HomePageClient, HomePageFallback } from "@/features/comparison";
import { JsonLd } from "@/components/seo/json-ld";
import { toAbsoluteUrl } from "@/lib/seo";

Expand Down Expand Up @@ -62,54 +61,6 @@ const softwareSchema = {
},
};

function HomePageFallback() {
return (
<div className="mx-auto w-full max-w-6xl flex-1 space-y-6 px-4 py-10">
<div className="rounded-2xl border border-border bg-card/90 p-6 shadow-lg backdrop-blur">
<div className="space-y-4 pb-4">
<Skeleton className="h-3 w-32 rounded-full" />
<Skeleton className="h-8 w-64 rounded-lg" />
<Skeleton className="h-4 w-full max-w-md rounded-lg" />
</div>

<div className="space-y-5">
<div className="grid gap-3 md:grid-cols-2">
<div className="space-y-1.5">
<Skeleton className="h-3 w-24 rounded-full" />
<Skeleton className="h-11 rounded-lg" />
</div>
<div className="space-y-1.5">
<Skeleton className="h-3 w-24 rounded-full" />
<Skeleton className="h-11 rounded-lg" />
</div>
</div>

<div className="space-y-2">
<Skeleton className="h-4 w-36 rounded-full" />
<div className="flex flex-wrap gap-2">
{Array.from({ length: 8 }).map((_, index) => (
<Skeleton key={index} className="h-7 w-20 rounded-full" />
))}
</div>
</div>

<div className="flex justify-end gap-3">
<Skeleton className="h-10 w-40 rounded-lg" />
<Skeleton className="h-10 w-10 rounded-lg" />
<Skeleton className="h-10 w-10 rounded-lg" />
</div>
</div>
</div>

<div className="flex flex-col items-center justify-center gap-4 py-20 text-center">
<Skeleton className="h-24 w-24 rounded-full sm:h-32 sm:w-32" />
<Skeleton className="h-6 w-64 rounded-lg" />
<Skeleton className="h-4 w-72 rounded-lg" />
</div>
</div>
);
}

export default function HomePage() {
return (
<>
Expand Down
95 changes: 7 additions & 88 deletions src/app/[locale]/user/[username]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,17 @@
import type { Metadata } from "next";
import { JsonLd } from "@/components/seo/json-ld";
import { UserProfileClient, UserNotFoundCard } from "@/features/developer";
import { getUserProfile } from "@/features/developer/services";
import {
getUserProfile,
buildUserProfileSchema,
buildUserBreadcrumbSchema,
} from "@/features/developer/services";
import { toAbsoluteUrl } from "@/lib/seo";

import countriesData from "@/data/countries.json";
import { detectCountry } from "@/lib/geo";

const getCachedUserProfile = cache(async (username: string) => {
return getUserProfile(username);
});

type CountryInfo = {
slug: string;
title: string;
};

const countries = countriesData as CountryInfo[];

export const revalidate = 1800; // Cache user profile on Edge CDN for 30 minutes via ISR
export const dynamicParams = true;

Expand Down Expand Up @@ -93,7 +87,7 @@
export default async function UserProfilePage({ params, searchParams }: Props) {
const { username } = await params;
const cleanUsername = decodeURIComponent(username.trim());
const profileUrl = toAbsoluteUrl(`/user/${cleanUsername}`);

Check warning on line 90 in src/app/[locale]/user/[username]/page.tsx

View workflow job for this annotation

GitHub Actions / Validate (Node 24.x)

'profileUrl' is assigned a value but never used

const resolvedSearchParams = searchParams ? await searchParams : undefined;
const countryParam = resolvedSearchParams?.country;
Expand All @@ -116,83 +110,8 @@
}

const { user, location } = profileData;
const displayName = user.name?.trim() || user.username;

const profilePageSchema = {
"@context": "https://schema.org",
"@type": "ProfilePage",
name: `${displayName} Developer Profile`,
description: `Open-source impact statistics and scoring for ${displayName} (@${user.username}).`,
url: profileUrl,
mainEntity: {
"@type": "Person",
name: displayName,
alternateName: user.username,
image: user.avatarUrl,
url: `https://github.com/${user.username}`,
...(location ? { homeLocation: location } : {}),
interactionStatistic: [
{
"@type": "InteractionCounter",
interactionType: "https://schema.org/LikeAction",
userInteractionCount: user.finalScore,
},
],
},
isPartOf: {
"@type": "WebSite",
name: "DevImpact",
url: toAbsoluteUrl("/"),
},
};

const detectedSlug = (countryParam || detectCountry(location))?.trim().toLowerCase();
const countryInfo = detectedSlug
? countries.find((c) => c.slug.toLowerCase() === detectedSlug)
: null;

const breadcrumbElements = [
{
"@type": "ListItem",
position: 1,
name: "Home",
item: toAbsoluteUrl("/"),
},
{
"@type": "ListItem",
position: 2,
name: "Leaderboards",
item: toAbsoluteUrl("/leaderboard"),
},
];

if (countryInfo) {
breadcrumbElements.push({
"@type": "ListItem",
position: 3,
name: countryInfo.title,
item: toAbsoluteUrl(`/leaderboard/${countryInfo.slug}`),
});
breadcrumbElements.push({
"@type": "ListItem",
position: 4,
name: displayName,
item: profileUrl,
});
} else {
breadcrumbElements.push({
"@type": "ListItem",
position: 3,
name: displayName,
item: profileUrl,
});
}

const breadcrumbSchema = {
"@context": "https://schema.org",
"@type": "BreadcrumbList",
itemListElement: breadcrumbElements,
};
const profilePageSchema = buildUserProfileSchema(user, location);
const breadcrumbSchema = buildUserBreadcrumbSchema(user, location, countryParam);

return (
<div className="mx-auto w-full max-w-5xl flex-1 px-4 py-8">
Expand Down
2 changes: 1 addition & 1 deletion src/app/api/compare/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
resolveLocale,
} from "@/features/comparison/services";
import { formatApiErrorResponse, parseSelectedLanguagesFromSearchParams } from "@/lib/api";
import { cleanGitHubUsername } from "@/utils/github";
import { cleanGitHubUsername } from "@/utils";

export const runtime = "nodejs";

Expand Down
2 changes: 1 addition & 1 deletion src/app/api/user/[username]/route.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { NextResponse } from "next/server";
import { getUserProfile } from "@/features/developer/services";
import { formatApiErrorResponse, parseSelectedLanguagesFromSearchParams } from "@/lib/api";
import { cleanGitHubUsername } from "@/utils/github";
import { cleanGitHubUsername } from "@/utils";

export const runtime = "nodejs";

Expand Down
4 changes: 2 additions & 2 deletions src/components/cards/community-card-item.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"use client";

import { MessageSquare, Star } from "lucide-react";
import { useTranslation } from "@/components/providers/language-provider";
import type { UserResult } from "@/features/developer/types";
import { useTranslation } from "@/components/providers";
import type { UserResult } from "@/features/developer";
import { StatChip } from "./work-card-helpers";

export type CommunityCardItemProps = {
Expand Down
4 changes: 2 additions & 2 deletions src/components/cards/pr-card-item.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"use client";

import { ArrowDown, ArrowUp, Star } from "lucide-react";
import { useTranslation } from "@/components/providers/language-provider";
import type { UserResult } from "@/features/developer/types";
import { useTranslation } from "@/components/providers";
import type { UserResult } from "@/features/developer";
import {
formatLanguageMatch,
LanguageBreakdown,
Expand Down
4 changes: 2 additions & 2 deletions src/components/cards/repo-card-item.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"use client";

import { Eye, GitFork, Star } from "lucide-react";
import { useTranslation } from "@/components/providers/language-provider";
import type { UserResult } from "@/features/developer/types";
import { useTranslation } from "@/components/providers";
import type { UserResult } from "@/features/developer";
import {
formatLanguageMatch,
LanguageBreakdown,
Expand Down
6 changes: 3 additions & 3 deletions src/components/cards/score-card.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"use client";

import { cn } from "@/utils/cn";
import { useTranslation } from "@/components/providers/language-provider";
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
import { cn } from "@/utils";
import { useTranslation } from "@/components/providers";
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui";

export type ScoreCardProps = {
title: string;
Expand Down
2 changes: 1 addition & 1 deletion src/components/cards/work-card-helpers.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use client";

import type { ReactNode } from "react";
import type { UserResult } from "@/features/developer/types";
import type { UserResult } from "@/features/developer";

export type LanguageEntry = {
name: string;
Expand Down
3 changes: 1 addition & 2 deletions src/components/layout/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
export * from "./app-header";
export * from "./app-footer";
export * from "./brand-logo";
export * from "./avatar";
export * from "./github-link";
export * from "./skeletons";
export { Avatar, type AvatarProps } from "@/components/ui/avatar";
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Image from "next/image";
import { cn } from "@/utils/cn";

type AvatarProps = {
export type AvatarProps = {
src?: string | null;
alt: string;
size?: number;
Expand All @@ -11,8 +11,7 @@ type AvatarProps = {
};

/**
* Reusable avatar image component.
*
* Reusable avatar image component with initial fallback.
*/
export function Avatar({
src,
Expand Down
1 change: 1 addition & 0 deletions src/components/ui/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ export * from "./progress";
export * from "./skeleton";
export * from "./tooltip";
export * from "./kbd";
export * from "./avatar";
60 changes: 0 additions & 60 deletions src/features/comparison/components/breakdown-bars.tsx

This file was deleted.

Loading
Loading