Skip to content

Commit aadadde

Browse files
b-at-neuclaude
andcommitted
#282 add page title metadata to all routes
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 28d4548 commit aadadde

12 files changed

Lines changed: 61 additions & 1 deletion

File tree

app/(main)/(auth)/applications/[id]/page.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { Metadata } from 'next';
12
import { notFound } from 'next/navigation';
23

34
import { getApplicationForReview } from '@/prisma/data/applications';
@@ -21,6 +22,16 @@ interface ApplicationDetailPageProps {
2122
params: Promise<{ id: string }>;
2223
}
2324

25+
export async function generateMetadata({
26+
params,
27+
}: ApplicationDetailPageProps): Promise<Metadata> {
28+
const { id } = await params;
29+
const user = await getCurrentUser();
30+
const application = await getApplicationForReview(id, user);
31+
if (!application) return {};
32+
return { title: application.user.name ?? application.user.email };
33+
}
34+
2435
export default async function ApplicationDetailPage({
2536
params,
2637
}: ApplicationDetailPageProps) {

app/(main)/(auth)/applications/page.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { Metadata } from 'next';
12
import { redirect } from 'next/navigation';
23

34
import {
@@ -20,6 +21,8 @@ import type {
2021
import { ApplicationsTable } from '@/components/features/applications-table';
2122
import { ApplicationsToolbar } from '@/components/features/applications-toolbar';
2223

24+
export const metadata: Metadata = { title: 'Applications' };
25+
2326
interface ApplicationsPageProps {
2427
searchParams: Promise<Record<string, string | string[] | undefined>>;
2528
}

app/(main)/(auth)/global-questions/page.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { Metadata } from 'next';
12
import { redirect } from 'next/navigation';
23

34
import { getGlobalQuestions } from '@/prisma/data/global-questions';
@@ -9,6 +10,8 @@ import { GlobalQuestionsTable } from '@/components/features/global-questions-tab
910
import { PageHeader } from '@/components/layouts/page-header';
1011
import { Button } from '@/components/ui/button';
1112

13+
export const metadata: Metadata = { title: 'Global Questions' };
14+
1215
export default async function GlobalQuestionsPage() {
1316
const user = await getCurrentUser();
1417
if (!user.isAdmin) redirect('/');

app/(main)/(auth)/my-applications/page.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1+
import type { Metadata } from 'next';
2+
13
import { getMyApplications } from '@/prisma/data/applications';
24

35
import { getCurrentUser } from '@/lib/auth/server';
46

57
import { MyApplicationsTable } from '@/components/features/my-applications-table';
68
import { PageHeader } from '@/components/layouts/page-header';
79

10+
export const metadata: Metadata = { title: 'My Applications' };
11+
812
export default async function MyApplicationsPage() {
913
const user = await getCurrentUser();
1014
const applications = await getMyApplications(user.id);

app/(main)/(auth)/positions/[id]/apply/page.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { Metadata } from 'next';
12
import Link from 'next/link';
23
import { redirect } from 'next/navigation';
34

@@ -13,6 +14,17 @@ import { PageHeader } from '@/components/layouts/page-header';
1314
import { Button } from '@/components/ui/button';
1415
import { Card, CardContent } from '@/components/ui/card';
1516

17+
export async function generateMetadata({
18+
params,
19+
}: {
20+
params: Promise<{ id: string }>;
21+
}): Promise<Metadata> {
22+
const { id } = await params;
23+
const position = await getPositionForApply(id);
24+
if (!position) return {};
25+
return { title: `Apply: ${position.title}` };
26+
}
27+
1628
export default async function ApplyPage({
1729
params,
1830
}: {

app/(main)/(auth)/positions/[id]/edit/page.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { Metadata } from 'next';
12
import { redirect } from 'next/navigation';
23

34
import { getPositionForEdit } from '@/prisma/data/positions';
@@ -14,6 +15,15 @@ interface EditPositionPageProps {
1415
params: Promise<{ id: string }>;
1516
}
1617

18+
export async function generateMetadata({
19+
params,
20+
}: EditPositionPageProps): Promise<Metadata> {
21+
const { id } = await params;
22+
const position = await getPositionForEdit(id);
23+
if (!position) return {};
24+
return { title: `Edit: ${position.title}` };
25+
}
26+
1727
export default async function EditPositionPage({
1828
params,
1929
}: EditPositionPageProps) {

app/(main)/(auth)/users/page.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { Metadata } from 'next';
12
import { redirect } from 'next/navigation';
23

34
import { getUsersForAdmin } from '@/prisma/data/users';
@@ -7,6 +8,8 @@ import { getCurrentUser } from '@/lib/auth/server';
78
import { UsersTable } from '@/components/features/users-table';
89
import { PageHeader } from '@/components/layouts/page-header';
910

11+
export const metadata: Metadata = { title: 'Users' };
12+
1013
export default async function UsersPage() {
1114
const user = await getCurrentUser();
1215
if (!user.isAdmin) redirect('/');

app/(main)/positions/page.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import type { Metadata } from 'next';
2+
13
import { Briefcase } from 'lucide-react';
24

35
import { getPositionApplicationStats } from '@/prisma/data/applications';
@@ -15,6 +17,8 @@ import { PositionCard } from '@/components/features/position-card';
1517
import { PositionCreateDialog } from '@/components/features/position-create-dialog';
1618
import { EmptyState } from '@/components/ui/empty-state';
1719

20+
export const metadata: Metadata = { title: 'Positions' };
21+
1822
export default async function PositionsPage() {
1923
const user = await getOptionalUser();
2024
const isAdmin = user?.isAdmin ?? false;

app/(main)/profile/page.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1+
import type { Metadata } from 'next';
2+
13
import { getProfileData } from '@/prisma/data/profile';
24

35
import { getCurrentUser } from '@/lib/auth/server';
46

57
import { ProfileForm } from '@/components/features/profile-form';
68
import { PageHeader } from '@/components/layouts/page-header';
79

10+
export const metadata: Metadata = { title: 'Profile' };
11+
812
export default async function ProfilePage() {
913
const user = await getCurrentUser();
1014
const profileData = await getProfileData(user.id);

app/layout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import './globals.css';
1111
const inter = Inter({ variable: '--font-sans', subsets: ['latin'] });
1212

1313
export const metadata: Metadata = {
14-
title: { default: 'Aplio', template: 'Aplio - %s' },
14+
title: { default: 'Aplio', template: 'Aplio %s' },
1515
description: 'A student government application management system.',
1616
icons: [
1717
// Light-mode favicon: white/light background logo

0 commit comments

Comments
 (0)