Skip to content

Commit dcf1c64

Browse files
committed
Sort gallery images
1 parent 0e512d8 commit dcf1c64

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/pages/gallery/[slug].astro

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,19 @@ export function getStaticPaths() {
1111
{ eager: true },
1212
);
1313
14-
return Object.entries(images).map(([path, image]) => ({
15-
params: {
16-
slug: path.split("/").pop() ?? "",
17-
},
18-
props: { image: image.default },
19-
}));
14+
const sortedImages = Object.entries(images)
15+
.sort(([a], [b]) => b.localeCompare(a)) // Sort descending (newer first)
16+
.map(([path, image]) => ({
17+
params: {
18+
slug: path.split("/").pop() ?? "",
19+
},
20+
props: { image: image.default },
21+
}));
22+
23+
return sortedImages;
2024
}
2125
26+
2227
const { slug } = Astro.params;
2328
const { image } = Astro.props;
2429

0 commit comments

Comments
 (0)