From 5f71f7d20552ebb5a758569fc20c9cde9b7d9759 Mon Sep 17 00:00:00 2001 From: Sawa <34698182+sawaYch@users.noreply.github.com> Date: Sat, 29 Jun 2024 04:38:26 +0800 Subject: [PATCH] fix(ui): gallery images set sort --- src/pages/gallery.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/pages/gallery.tsx b/src/pages/gallery.tsx index 94e9fd61..ecaae95a 100644 --- a/src/pages/gallery.tsx +++ b/src/pages/gallery.tsx @@ -90,7 +90,15 @@ export const galleryQuery = graphql` const GalleryPage = ({ ...queryResponse }: PageProps) => { - const data = queryResponse.data.allStrapiGallery.nodes; + const data = useMemo(() => { + const d: GalleryData[] = queryResponse.data.allStrapiGallery + .nodes as unknown as GalleryData[]; + return d.map((it) => { + const dd = it; + dd.image = [...it.image.sort((a, b) => a.name.localeCompare(b.name))]; + return dd; + }); + }, [queryResponse.data.allStrapiGallery.nodes]); const variants = useMemo( () => ({