mirror of
https://github.com/Afilmory/afilmory
synced 2026-04-24 23:05:05 +00:00
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:
@@ -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 =
|
||||
|
||||
Reference in New Issue
Block a user