import getData from "@/api"; import styles from "./style.module.scss"; import EditionElement from "@/components/editionElement"; import EditionGallery from "@/components/editionGallery"; import PressBlock from "@/components/pressBlock"; import Empty from "@/components/empty"; import VideoBlock from "@/components/videoBlock"; import Fanfare from "@/components/fanfare"; export const dynamic = "force-dynamic"; export async function generateMetadata({ params }) { const data = await getData(`editions/${params.editionId}`, { populate: { flyer: { fields: ["name", "alternativeText", "caption", "url"], }, }, filters: { $or: [{ id: { $eq: params.editionId } }], }, }); const activeEditionData = await getData("site", { populate: { edition: { fields: ["id"], }, }, fields: ["author"], }); const activeEdition = activeEditionData?.data?.attributes.edition.data.id; const edition = data.data?.attributes.publishedAt ? data : null; const flyer = edition?.data?.attributes.flyer.data.attributes; return edition ? { metadataBase: `${process.env.NEXT_PUBLIC_ORIGIN}`, title: edition.title, description: edition.description, alternates: { canonical: data.data.id !== activeEdition ? `${process.env.NEXT_PUBLIC_ORIGIN}/editions/${params.editionId}` : `${process.env.NEXT_PUBLIC_ORIGIN}`, }, openGraph: { title: edition.title, url: data.data.id !== activeEdition ? `${process.env.NEXT_PUBLIC_ORIGIN}/editions/${params.editionId}` : `${process.env.NEXT_PUBLIC_ORIGIN}`, description: edition.description, images: { url: `${process.env.NEXT_PUBLIC_IMG_URI}${flyer.url}`, width: flyer.width, height: flyer.height, }, authors: [activeEditionData.data.attributes.author], type: "website", locale: "fr_FR", siteName: "Le Fefan - Festival de Fanfares", }, } : {}; } export default async function Edition({ params }) { const data = await getData(`editions/${params.editionId}`, { populate: { flyer: { fields: ["name", "alternativeText", "caption", "url"], }, gallery: { fields: ["name", "alternativeText", "caption", "url"], }, programs: { fields: ["map_uri", "introduction", "description", "title", "type"], populate: { bands: { fields: ["name", "location"], }, }, }, statistics: { fields: ["name", "value", "publishedAt"], }, social_links: { fields: ["uri", "type"], }, articles: { fields: ["title", "link", "excerpt", "publishedAt"], }, fields: ["movie"], }, filters: { $or: [{ id: { $eq: params.editionId } }], }, }); const edition = data.data?.attributes.publishedAt ? data : null; const flyer = edition?.data?.attributes.flyer.data.attributes; const gallery = edition?.data?.attributes.gallery.data; const statistics = edition?.data?.attributes.statistics.data; const allArticles = edition?.data?.attributes.articles.data; const articles = allArticles ? allArticles.filter((el) => el.attributes.publishedAt != null) : []; const movie = edition.data.attributes.movie ? edition.data.attributes.movie : null; const programs = edition?.data?.attributes?.programs?.data ? edition.data.attributes.programs.data : []; const program = programs.filter((el) => el.attributes.type === "city-wide")[0] ?? null; const bands = program ? program?.attributes?.bands.data : []; return (
{edition ? ( <>

{edition.data.attributes.title}

{edition.data.attributes.subtitle}

({ id, type: "stat", title: attributes.name, value: attributes.value, }))} /> {movie && bands ? (
{bands.length > 0 ? (

Les fanfares

{bands.map(({ id, attributes: attr }) => { return ( ); })}
) : null} {movie ? ( <> ) : null}
) : null} {articles.length > 0 ? ( <>

Ils ont parlé de nous !

{articles.map(({ id, attributes }, index) => { const offset = index + (articles.length - gallery.length) / 2; return index < gallery.length ? ( ) : ( ); })} ) : null} {articles.length <= gallery.length ? ( <>

Les photos du Fefan

) : null} ) : ( )}
); }