Maj taxonomies
Some checks failed
Build and Push App / build (push) Failing after 11m28s

maj url photo
+ page 404
+ gestion programmation d'article
This commit is contained in:
2026-05-03 21:22:12 +02:00
parent 0e72867d4c
commit 5f421b418e
41 changed files with 1946 additions and 735 deletions

View File

@@ -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>
);
}

View File

@@ -19,10 +19,17 @@ export default async function AfroLifePage({ searchParams }: Props) {
const filter = allowedFilters.includes(rawFilter) ? rawFilter : 'ALL';
let items: any[] = [];
const now = new Date();
try {
if (filter === 'EVENT') {
const events = await prisma.event.findMany({
where: {
status: 'PUBLISHED',
publishedAt: {
lte: now
}
},
orderBy: { date: 'desc' }
});
items = events.map(e => ({
@@ -34,7 +41,12 @@ export default async function AfroLifePage({ searchParams }: Props) {
duration: new Date(e.date).toLocaleDateString('fr-FR')
}));
} else {
const where: any = {};
const where: any = {
status: 'PUBLISHED',
publishedAt: {
lte: now
}
};
if (filter !== 'ALL') {
where.type = filter as InterviewType;
}
@@ -47,6 +59,12 @@ export default async function AfroLifePage({ searchParams }: Props) {
// If 'ALL', we might want to also fetch events and mix them
if (filter === 'ALL') {
const events = await prisma.event.findMany({
where: {
status: 'PUBLISHED',
publishedAt: {
lte: now
}
},
orderBy: { date: 'desc' },
take: 10
});