maj url photo + page 404 + gestion programmation d'article
This commit is contained in:
@@ -14,16 +14,21 @@ interface Props {
|
||||
|
||||
export async function generateMetadata({ params }: Props): Promise<Metadata> {
|
||||
const { id } = await params;
|
||||
const now = new Date();
|
||||
|
||||
const interview = await prisma.interview.findFirst({
|
||||
where: {
|
||||
OR: [{ id }, { slug: id }]
|
||||
OR: [{ id }, { slug: id }],
|
||||
publishedAt: { lte: now },
|
||||
status: 'PUBLISHED'
|
||||
}
|
||||
});
|
||||
|
||||
const event = !interview ? await prisma.event.findFirst({
|
||||
where: {
|
||||
OR: [{ id }, { slug: id }]
|
||||
OR: [{ id }, { slug: id }],
|
||||
publishedAt: { lte: now },
|
||||
status: 'PUBLISHED'
|
||||
}
|
||||
}) : null;
|
||||
|
||||
@@ -47,18 +52,23 @@ export async function generateMetadata({ params }: Props): Promise<Metadata> {
|
||||
|
||||
export default async function AfroLifeDetailPage({ params }: Props) {
|
||||
const { id } = await params;
|
||||
const now = new Date();
|
||||
|
||||
// 1. Try to find an interview
|
||||
const interview = await prisma.interview.findFirst({
|
||||
where: {
|
||||
OR: [{ id }, { slug: id }]
|
||||
OR: [{ id }, { slug: id }],
|
||||
publishedAt: { lte: now },
|
||||
status: 'PUBLISHED'
|
||||
}
|
||||
});
|
||||
|
||||
// 2. If not found, try to find an event
|
||||
const event = !interview ? await prisma.event.findFirst({
|
||||
where: {
|
||||
OR: [{ id }, { slug: id }]
|
||||
OR: [{ id }, { slug: id }],
|
||||
publishedAt: { lte: now },
|
||||
status: 'PUBLISHED'
|
||||
}
|
||||
}) : null;
|
||||
|
||||
@@ -157,7 +167,7 @@ export default async function AfroLifeDetailPage({ params }: Props) {
|
||||
)}
|
||||
|
||||
{/* Description / Article Content / Event Content */}
|
||||
<div className="prose prose-lg prose-orange max-w-none mx-auto text-gray-600 break-words overflow-hidden">
|
||||
<div className="prose prose-lg prose-orange max-w-none mx-auto text-gray-600">
|
||||
{isEvent ? (
|
||||
<div dangerouslySetInnerHTML={{ __html: sanitizeHTML((event as any).description) }} />
|
||||
) : (
|
||||
@@ -195,4 +205,3 @@ export default async function AfroLifeDetailPage({ params }: Props) {
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user