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