fix(generate-og-image): handle missing EXIF date values to prevent sorting errors

- Added a check to ensure that both photos have valid EXIF DateTimeOriginal values before sorting, preventing potential errors when the data is missing.

Signed-off-by: Innei <tukon479@gmail.com>
This commit is contained in:
Innei
2025-06-11 01:39:55 +08:00
parent eb507f9359
commit 09e6f439d7

View File

@@ -12,6 +12,13 @@ async function getLatestPhotos(count = 4) {
// 按拍摄时间排序,获取最新的照片
const sortedPhotos = photos.sort((a, b) => {
if (
!a?.exif?.Photo?.DateTimeOriginal ||
!b?.exif?.Photo?.DateTimeOriginal
) {
return 0
}
const aDate =
(a.exif.Photo?.DateTimeOriginal as unknown as string) || a.lastModified
const bDate =