diff --git a/src/app/thumbnails/[thumbnailId]/page.tsx b/src/app/thumbnails/[thumbnailId]/page.tsx index edef84a..4fddca7 100644 --- a/src/app/thumbnails/[thumbnailId]/page.tsx +++ b/src/app/thumbnails/[thumbnailId]/page.tsx @@ -136,6 +136,14 @@ export default function ThumbnailPage() { : thumbnail.voteIds.includes(user._id)) ); + const sortedImages = thumbnail.images + .map((image) => image) + .sort((a, b) => { + const aVotes = getVotesFor(thumbnail, a); + const bVotes = getVotesFor(thumbnail, b); + return bVotes - aVotes; + }); + return (
@@ -152,47 +160,105 @@ export default function ThumbnailPage() {
-
- - -
- - -
- {currentImageIndex + 1} of {thumbnail.images.length} + {!hasVoted && ( +
+ + +
+ + +
+ {currentImageIndex + 1} of {thumbnail.images.length} +
+ +
+
+ )} + + {hasVoted && ( +
+ {sortedImages.map((imageId) => ( +
+
+ image test a + +
+ + + + CN + + +
+
+ {thumbnail.title} +
+
+ {thumbnail.name} +
+
+
152K Views
+ + {formatDistance( + new Date(thumbnail._creationTime), + new Date(), + { + addSuffix: true, + } + )} +
+
+
+
- +
+ +
+ {getVotesFor(thumbnail, imageId)} votes +
+
+
+ ))}
-
+ )}