add(previous-edition): add sort editions by title
All checks were successful
Deploy Fefan / deploy (push) Successful in 3m30s
All checks were successful
Deploy Fefan / deploy (push) Successful in 3m30s
This commit is contained in:
@@ -1,24 +1,24 @@
|
|||||||
import getData from "@/api";
|
import getData from '@/api';
|
||||||
import styles from "./style.module.scss";
|
import EditionElement from '@/components/editionElement';
|
||||||
import EditionElement from "@/components/editionElement";
|
import Empty from '@/components/empty';
|
||||||
import Empty from "@/components/empty";
|
import styles from './style.module.scss';
|
||||||
export const dynamic = "force-dynamic";
|
export const dynamic = 'force-dynamic';
|
||||||
|
|
||||||
export async function generateMetadata() {
|
export async function generateMetadata() {
|
||||||
const site = await getData("site", {
|
const site = await getData('site', {
|
||||||
fields: ["description", "author"],
|
fields: ['description', 'author'],
|
||||||
});
|
});
|
||||||
|
|
||||||
const data = await getData("editions", {
|
const data = await getData('editions', {
|
||||||
populate: {
|
populate: {
|
||||||
gallery: {
|
gallery: {
|
||||||
fields: ["name", "url", "alternativeText"],
|
fields: ['name', 'url', 'alternativeText'],
|
||||||
},
|
},
|
||||||
statistics: {
|
statistics: {
|
||||||
fields: ["name", "value"],
|
fields: ['name', 'value'],
|
||||||
},
|
},
|
||||||
flyer: {
|
flyer: {
|
||||||
fields: ["name", "url", "alternativeText", "width", "height"],
|
fields: ['name', 'url', 'alternativeText', 'width', 'height'],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@@ -27,13 +27,13 @@ export async function generateMetadata() {
|
|||||||
return site.data
|
return site.data
|
||||||
? {
|
? {
|
||||||
metadataBase: `${process.env.NEXT_PUBLIC_ORIGIN}`,
|
metadataBase: `${process.env.NEXT_PUBLIC_ORIGIN}`,
|
||||||
title: "Editions précédentes — Le Fefan",
|
title: 'Editions précédentes — Le Fefan',
|
||||||
description: site.data.attributes.description,
|
description: site.data.attributes.description,
|
||||||
alternates: {
|
alternates: {
|
||||||
canonical: "/editions",
|
canonical: '/editions',
|
||||||
},
|
},
|
||||||
openGraph: {
|
openGraph: {
|
||||||
title: "Editions précédentes — Le Fefan",
|
title: 'Editions précédentes — Le Fefan',
|
||||||
url: `${process.env.NEXT_PUBLIC_ORIGIN}/prog/city-wide`,
|
url: `${process.env.NEXT_PUBLIC_ORIGIN}/prog/city-wide`,
|
||||||
description: site.data.attributes.description,
|
description: site.data.attributes.description,
|
||||||
images: editions.map(({ attributes: attr }) => ({
|
images: editions.map(({ attributes: attr }) => ({
|
||||||
@@ -43,41 +43,42 @@ export async function generateMetadata() {
|
|||||||
url: attr.flyer.data.attributes.url,
|
url: attr.flyer.data.attributes.url,
|
||||||
})),
|
})),
|
||||||
authors: [site.data.attributes.author],
|
authors: [site.data.attributes.author],
|
||||||
type: "website",
|
type: 'website',
|
||||||
locale: "fr_FR",
|
locale: 'fr_FR',
|
||||||
siteName: "Le Fefan - Festival de Fanfares",
|
siteName: 'Le Fefan - Festival de Fanfares',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
: {};
|
: {};
|
||||||
}
|
}
|
||||||
|
|
||||||
export default async function Editions() {
|
export default async function Editions() {
|
||||||
const site = await getData("site", {
|
const site = await getData('site', {
|
||||||
fields: ["id"],
|
fields: ['id'],
|
||||||
populate: {
|
populate: {
|
||||||
edition: {
|
edition: {
|
||||||
fields: ["id"],
|
fields: ['id'],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const data = await getData("editions", {
|
const data = await getData('editions', {
|
||||||
populate: {
|
populate: {
|
||||||
gallery: {
|
gallery: {
|
||||||
fields: ["name", "url", "alternativeText"],
|
fields: ['name', 'url', 'alternativeText'],
|
||||||
},
|
},
|
||||||
statistics: {
|
statistics: {
|
||||||
fields: ["name", "value"],
|
fields: ['name', 'value'],
|
||||||
},
|
},
|
||||||
flyer: {
|
flyer: {
|
||||||
fields: ["name", "url", "alternativeText"],
|
fields: ['name', 'url', 'alternativeText'],
|
||||||
},
|
},
|
||||||
fields: ["movie"],
|
fields: ['movie'],
|
||||||
},
|
},
|
||||||
|
sort: ['title:desc'],
|
||||||
});
|
});
|
||||||
|
|
||||||
const editions = (data.data ?? []).filter(
|
const editions = (data.data ?? []).filter(
|
||||||
(e) => e.id !== site.data?.attributes.edition.data?.id
|
(e) => e.id !== site.data?.attributes.edition.data?.id,
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -86,24 +87,24 @@ export default async function Editions() {
|
|||||||
editions.map(({ id, attributes: attr }) => {
|
editions.map(({ id, attributes: attr }) => {
|
||||||
const stats = attr.statistics.data.map(({ id, attributes }) => ({
|
const stats = attr.statistics.data.map(({ id, attributes }) => ({
|
||||||
id,
|
id,
|
||||||
type: "stat",
|
type: 'stat',
|
||||||
title: attributes.name,
|
title: attributes.name,
|
||||||
value: attributes.value,
|
value: attributes.value,
|
||||||
}));
|
}));
|
||||||
const images = attr.gallery.data.map(({ id, attributes }) => ({
|
const images = attr.gallery.data.map(({ id, attributes }) => ({
|
||||||
id,
|
id,
|
||||||
type: "image",
|
type: 'image',
|
||||||
title: attributes.alternativeText,
|
title: attributes.alternativeText,
|
||||||
value: `${process.env.NEXT_PUBLIC_IMG_URI}${attributes.url}`,
|
value: `${process.env.NEXT_PUBLIC_IMG_URI}${attributes.url}`,
|
||||||
}));
|
}));
|
||||||
const movie = attr.movie
|
const movie = attr.movie
|
||||||
? [
|
? [
|
||||||
{
|
{
|
||||||
id: "movie",
|
id: 'movie',
|
||||||
type: "video",
|
type: 'video',
|
||||||
title: `Aftermovie ${attr.title}`,
|
title: `Aftermovie ${attr.title}`,
|
||||||
value: attr.movie,
|
value: attr.movie,
|
||||||
mode: "thumbnail",
|
mode: 'thumbnail',
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
: null;
|
: null;
|
||||||
|
|||||||
Reference in New Issue
Block a user