fix: optimize photo processing in generateOGImage function

- Changed the iteration logic to process photos in reverse order, improving the handling of the latest photos.
- Introduced a variable to store the minimum length for cleaner and more readable code.

Signed-off-by: Innei <tukon479@gmail.com>
This commit is contained in:
Innei
2025-06-07 17:59:49 +08:00
parent a76462fa85
commit 7e1600c7e8

View File

@@ -263,7 +263,8 @@ export async function generateOGImage(options: OGImageOptions) {
{ x: 270, y: 70 },
]
for (let i = 0; i < Math.min(latestPhotos.length, photoCount); i++) {
const length = Math.min(latestPhotos.length, photoCount)
for (let i = length - 1; i >= 0; i--) {
const photo = latestPhotos[i]
const thumbnailBuffer = await downloadAndProcessThumbnail(
photo.thumbnailUrl,