Skip to content

Commit 94eea99

Browse files
committed
fix ogimage for profile page
1 parent 55abc59 commit 94eea99

File tree

2 files changed

+21
-20
lines changed

2 files changed

+21
-20
lines changed

app/profile/[login]/layout.tsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,38 @@
11
'use cache';
2+
import { Metadata } from 'next';
23
import { unstable_cacheLife as cacheLife, unstable_cacheTag as cacheTag } from 'next/cache';
34
import { Suspense } from 'react';
45

56
import { Header } from '@/components/header/header';
67
import { Tab } from '@/components/tabs/tabs';
78
import { TabsBar } from '@/components/tabs/tabs-bar';
9+
import { fetchProfileData } from '@/graphql/helpers/fetch-profile-data';
810
import { graphqlDirect } from '@/lib/graphql/graphql-direct';
911
import { TopGlobalRankingsDocument } from '@/types/generated/graphql';
1012

1113
import Loading from './loading';
1214

1315
type ProfileLayoutProps = Readonly<{ children: React.ReactNode; params: Promise<{ login: string }> }>;
1416

17+
export async function generateMetadata({ params }: { params: Promise<{ login: string }> }): Promise<Metadata> {
18+
const { login } = await params;
19+
const { user } = await fetchProfileData(login);
20+
21+
if (!user) {
22+
return { title: 'GitHub Profile Analytics & Rankings · GitRanks' };
23+
}
24+
25+
const { s, c, f } = user.rankGlobal ?? {};
26+
27+
return {
28+
title: `${login} · GitHub Profile Analytics · GitRanks`,
29+
description: `Explore GitHub profile analytics for ${login} – ranked #${s} by stars, #${c} by contributions, and #${f} by followers.`,
30+
openGraph: {
31+
images: [user.avatarUrl!],
32+
},
33+
};
34+
}
35+
1536
export async function generateStaticParams() {
1637
const { byStars, byContribution, byFollowers } = (await graphqlDirect(TopGlobalRankingsDocument)) ?? {};
1738
const mergedRanks = [...byStars, ...byContribution, ...byFollowers];

app/profile/[login]/timeline/page.tsx

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
'use cache';
22

3-
import { Metadata } from 'next';
43
import { unstable_cacheLife as cacheLife, unstable_cacheTag as cacheTag } from 'next/cache';
54
import { notFound } from 'next/navigation';
65

@@ -10,25 +9,6 @@ import { fetchProfileTimeline } from '@/graphql/helpers/fetch-profile-timeline';
109
import { LayoutLeftColumn } from '../components/layout-left-column';
1110
import { ProfileTimeline } from './components/profile-timeline';
1211

13-
export async function generateMetadata({ params }: { params: Promise<{ login: string }> }): Promise<Metadata> {
14-
const { login } = await params;
15-
const { user } = await fetchProfileData(login);
16-
17-
if (!user) {
18-
return { title: 'GitHub Profile Analytics & Rankings · GitRanks' };
19-
}
20-
21-
const { s, c, f } = user.rankGlobal ?? {};
22-
23-
return {
24-
title: `${login} Timeline · GitRanks`,
25-
description: `Explore GitHub analytics for ${login} – ranked #${s} by stars, #${c} by contributions, and #${f} by followers. See how your code impacts the world and where you stand in the global developer community with GitRanks.`,
26-
openGraph: {
27-
images: [user.avatarUrl!],
28-
},
29-
};
30-
}
31-
3212
export default async function Timeline({ params }: { params: Promise<{ login: string }> }) {
3313
const { login } = await params;
3414
cacheLife('hours');

0 commit comments

Comments
 (0)