We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0e512d8 commit dcf1c64Copy full SHA for dcf1c64
src/pages/gallery/[slug].astro
@@ -11,14 +11,19 @@ export function getStaticPaths() {
11
{ eager: true },
12
);
13
14
- return Object.entries(images).map(([path, image]) => ({
15
- params: {
16
- slug: path.split("/").pop() ?? "",
17
- },
18
- props: { image: image.default },
19
- }));
+ const sortedImages = Object.entries(images)
+ .sort(([a], [b]) => b.localeCompare(a)) // Sort descending (newer first)
+ .map(([path, image]) => ({
+ params: {
+ slug: path.split("/").pop() ?? "",
+ },
20
+ props: { image: image.default },
21
+ }));
22
+
23
+ return sortedImages;
24
}
25
26
27
const { slug } = Astro.params;
28
const { image } = Astro.props;
29
0 commit comments