build error fixes
This commit is contained in:
@ -4,25 +4,21 @@ import { Footer } from "../../../components/Layouts/Footer";
|
||||
import TeamMemberDetail from "../../../components/faculty/TeamMemberDetail";
|
||||
import { notFound } from 'next/navigation';
|
||||
import { FacultyService } from '../../../lib/facultyData';
|
||||
import type { Metadata } from 'next';
|
||||
|
||||
interface FacultyPageProps {
|
||||
params: {
|
||||
id: string;
|
||||
};
|
||||
}
|
||||
|
||||
export default async function FacultyPage({ params }: FacultyPageProps) {
|
||||
export default async function FacultyPage({
|
||||
params,
|
||||
}: {
|
||||
params: { id: string };
|
||||
}) {
|
||||
const memberId = parseInt(params.id);
|
||||
|
||||
// Check if ID is valid number
|
||||
|
||||
if (isNaN(memberId)) {
|
||||
notFound();
|
||||
}
|
||||
|
||||
// Fetch member data from API
|
||||
|
||||
const memberData = await FacultyService.getFacultyById(memberId);
|
||||
|
||||
// If member not found, show 404
|
||||
if (!memberData) {
|
||||
notFound();
|
||||
}
|
||||
@ -36,38 +32,37 @@ export default async function FacultyPage({ params }: FacultyPageProps) {
|
||||
);
|
||||
}
|
||||
|
||||
// Generate static params for all team members
|
||||
// Generate static params
|
||||
export async function generateStaticParams() {
|
||||
try {
|
||||
const teamMembers = await FacultyService.getAllFaculty();
|
||||
|
||||
|
||||
return teamMembers.map((member) => ({
|
||||
id: member.id.toString(),
|
||||
}));
|
||||
} catch (error) {
|
||||
console.error('Error generating static params:', error);
|
||||
// Return empty array if data fetching fails during build
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
// Generate metadata for each team member page
|
||||
export async function generateMetadata({ params }: FacultyPageProps) {
|
||||
// Generate metadata
|
||||
export async function generateMetadata({
|
||||
params,
|
||||
}: {
|
||||
params: { id: string };
|
||||
}): Promise<Metadata> {
|
||||
const memberId = parseInt(params.id);
|
||||
|
||||
|
||||
if (isNaN(memberId)) {
|
||||
return {
|
||||
title: 'Faculty Member Not Found - CMC Vellore'
|
||||
};
|
||||
return { title: 'Faculty Member Not Found - CMC Vellore' };
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
const memberData = await FacultyService.getFacultyById(memberId);
|
||||
|
||||
|
||||
if (!memberData) {
|
||||
return {
|
||||
title: 'Faculty Member Not Found - CMC Vellore'
|
||||
};
|
||||
return { title: 'Faculty Member Not Found - CMC Vellore' };
|
||||
}
|
||||
|
||||
return {
|
||||
@ -81,8 +76,6 @@ export async function generateMetadata({ params }: FacultyPageProps) {
|
||||
};
|
||||
} catch (error) {
|
||||
console.error('Error generating metadata:', error);
|
||||
return {
|
||||
title: 'Faculty Member - CMC Vellore'
|
||||
};
|
||||
return { title: 'Faculty Member - CMC Vellore' };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user