Skip to content

Commit 8f35e61

Browse files
committed
Add canonical URLs to metadata on all pages
1 parent a2a1fd6 commit 8f35e61

21 files changed

Lines changed: 222 additions & 44 deletions

File tree

apps/frontend/app/about/page.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ import Link from 'next/link';
33
export const metadata = {
44
title: 'About - Teerank',
55
description: 'Teerank is a simple and fast ranking system for Teeworlds.',
6+
alternates: {
7+
canonical: 'https://teerank.io/about',
8+
},
69
};
710

811
export default function Index() {

apps/frontend/app/all/clans/page.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ import { searchParamSchema } from '../schema';
77
export const metadata = {
88
title: 'All Clans - Teerank',
99
description: 'Teerank is a simple and fast ranking system for Teeworlds.',
10+
alternates: {
11+
canonical: 'https://teerank.io/all/clans',
12+
},
1013
};
1114

1215
export default async function Index({

apps/frontend/app/all/page.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ import redis from '../../utils/redis';
77
export const metadata = {
88
title: 'All Players - Teerank',
99
description: 'Teerank is a simple and fast ranking system for Teeworlds.',
10+
alternates: {
11+
canonical: 'https://teerank.io/all',
12+
},
1013
};
1114

1215
export default async function Index({

apps/frontend/app/all/servers/page.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ import redis from '../../../utils/redis';
77
export const metadata = {
88
title: 'All Servers - Teerank',
99
description: 'Teerank is a simple and fast ranking system for Teeworlds.',
10+
alternates: {
11+
canonical: 'https://teerank.io/all/servers',
12+
},
1013
};
1114

1215
export default async function Index({

apps/frontend/app/clan/[clanName]/gametypes/page.tsx

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,24 @@ import { notFound } from 'next/navigation';
44
import prisma from '../../../../utils/prisma';
55
import { GameTypeList } from '../../../../components/GameTypeList';
66
import { searchParamPageSchema } from '../../../../utils/page';
7+
import { encodeString } from '../../../../utils/encoding';
8+
import { Metadata } from 'next';
79

8-
export const metadata = {
9-
title: 'Clan - Game types',
10-
description: 'A Teeworlds clan',
11-
};
10+
export async function generateMetadata({
11+
params,
12+
}: {
13+
params: z.infer<typeof paramsSchema>;
14+
}): Promise<Metadata> {
15+
const { clanName } = paramsSchema.parse(params);
16+
17+
return {
18+
title: `Clan ${clanName} - Maps`,
19+
description: `List of ranked maps for ${clanName}`,
20+
alternates: {
21+
canonical: `https://teerank.io/clan/${encodeString(clanName)}/gametypes`,
22+
},
23+
};
24+
}
1225

1326
export default async function Index({
1427
params,

apps/frontend/app/clan/[clanName]/maps/page.tsx

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,24 @@ import { notFound } from 'next/navigation';
44
import prisma from '../../../../utils/prisma';
55
import { searchParamPageSchema } from '../../../../utils/page';
66
import { MapList } from '../../../../components/MapList';
7+
import { encodeString } from '../../../../utils/encoding';
8+
import { Metadata } from 'next';
79

8-
export const metadata = {
9-
title: 'Clan - Maps',
10-
description: 'A Teeworlds clan',
11-
};
10+
export async function generateMetadata({
11+
params,
12+
}: {
13+
params: z.infer<typeof paramsSchema>;
14+
}): Promise<Metadata> {
15+
const { clanName } = paramsSchema.parse(params);
16+
17+
return {
18+
title: `Clan ${clanName} - Maps`,
19+
description: `List of ranked maps for ${clanName}`,
20+
alternates: {
21+
canonical: `https://teerank.io/clan/${encodeString(clanName)}/maps`,
22+
},
23+
};
24+
}
1225

1326
export default async function Index({
1427
params,

apps/frontend/app/clan/[clanName]/page.tsx

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,24 @@ import { notFound } from 'next/navigation';
44
import prisma from '../../../utils/prisma';
55
import { PlayerList } from '../../../components/PlayerList';
66
import { searchParamPageSchema } from '../../../utils/page';
7+
import { Metadata } from 'next';
8+
import { encodeString } from '../../../utils/encoding';
79

8-
export const metadata = {
9-
title: 'Clan',
10-
description: 'A Teeworlds clan',
11-
};
10+
export async function generateMetadata({
11+
params,
12+
}: {
13+
params: z.infer<typeof paramsSchema>;
14+
}): Promise<Metadata> {
15+
const { clanName } = paramsSchema.parse(params);
16+
17+
return {
18+
title: `Clan ${clanName}`,
19+
description: `List of ranked players for ${clanName}`,
20+
alternates: {
21+
canonical: `https://teerank.io/clan/${encodeString(clanName)}`,
22+
},
23+
};
24+
}
1225

1326
export default async function Index({
1427
params,

apps/frontend/app/gametype/[gameTypeName]/(lists)/clans/page.tsx

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,26 @@
1+
import { Metadata } from 'next';
12
import { ClanList } from '../../../../../components/ClanList';
3+
import { encodeString } from '../../../../../utils/encoding';
24
import prisma from '../../../../../utils/prisma';
35
import { paramsSchema, searchParamsSchema } from '../../schema';
46
import { notFound } from 'next/navigation';
7+
import { z } from 'zod';
58

6-
export const metadata = {
7-
title: 'Clans',
8-
description: 'List of ranked clans',
9-
};
9+
export async function generateMetadata({
10+
params,
11+
}: {
12+
params: z.infer<typeof paramsSchema>;
13+
}): Promise<Metadata> {
14+
const { gameTypeName } = paramsSchema.parse(params);
15+
16+
return {
17+
title: `Gametype ${gameTypeName}`,
18+
description: `List of ranked clans for ${gameTypeName}`,
19+
alternates: {
20+
canonical: `https://teerank.io/gametype/${encodeString(gameTypeName)}/clans`,
21+
},
22+
};
23+
}
1024

1125
export default async function Index({
1226
params,

apps/frontend/app/gametype/[gameTypeName]/(lists)/page.tsx

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,25 @@ import { PlayerList } from '../../../../components/PlayerList';
33
import prisma from '../../../../utils/prisma';
44
import { paramsSchema, searchParamsSchema } from '../schema';
55
import { notFound } from 'next/navigation';
6+
import { encodeString } from '../../../../utils/encoding';
7+
import { Metadata } from 'next';
8+
import { z } from 'zod';
69

7-
export const metadata = {
8-
title: 'Players',
9-
description: 'List of ranked players',
10-
};
10+
export async function generateMetadata({
11+
params,
12+
}: {
13+
params: z.infer<typeof paramsSchema>;
14+
}): Promise<Metadata> {
15+
const { gameTypeName } = paramsSchema.parse(params);
16+
17+
return {
18+
title: `Gametype ${gameTypeName}`,
19+
description: `List of ranked players for ${gameTypeName}`,
20+
alternates: {
21+
canonical: `https://teerank.io/gametype/${encodeString(gameTypeName)}`,
22+
},
23+
};
24+
}
1125

1226
export default async function Index({
1327
params,

apps/frontend/app/gametype/[gameTypeName]/(lists)/servers/page.tsx

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,25 @@
1+
import { Metadata } from 'next';
12
import { ServerList } from '../../../../../components/ServerList';
3+
import { encodeString } from '../../../../../utils/encoding';
24
import prisma from '../../../../../utils/prisma';
35
import { paramsSchema, searchParamsSchema } from '../../schema';
6+
import { z } from 'zod';
47

5-
export const metadata = {
6-
title: 'Servers',
7-
description: 'List of ranked servers',
8-
};
8+
export async function generateMetadata({
9+
params,
10+
}: {
11+
params: z.infer<typeof paramsSchema>;
12+
}): Promise<Metadata> {
13+
const { gameTypeName } = paramsSchema.parse(params);
14+
15+
return {
16+
title: `Gametype ${gameTypeName}`,
17+
description: `List of ranked servers for ${gameTypeName}`,
18+
alternates: {
19+
canonical: `https://teerank.io/gametype/${encodeString(gameTypeName)}/servers`,
20+
},
21+
};
22+
}
923

1024
export default async function Index({
1125
params,

0 commit comments

Comments
 (0)