From c4009391c030635d1e853dfa70efa2f0e7027cc8 Mon Sep 17 00:00:00 2001 From: Scott Idem Date: Thu, 12 Feb 2026 15:22:28 -0500 Subject: [PATCH] fix(posts): robust date sorting in post and comment processors --- src/lib/ae_posts/ae_posts__post.ts | 5 +++-- src/lib/ae_posts/ae_posts__post_comment.ts | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/lib/ae_posts/ae_posts__post.ts b/src/lib/ae_posts/ae_posts__post.ts index 3cc44db3..13f91a93 100644 --- a/src/lib/ae_posts/ae_posts__post.ts +++ b/src/lib/ae_posts/ae_posts__post.ts @@ -549,12 +549,13 @@ export async function process_ae_obj__post_props({ } obj.name = obj.title; const sort_val = (obj.sort ?? 0).toString().padStart(3, '0'); + const updated = obj.updated_on ?? obj.created_on ?? new Date(0).toISOString(); obj.tmp_sort_1 = `${obj.group ?? ''}_${obj.priority ? '1' : '0'}_${ sort_val - }_${obj.updated_on ?? obj.created_on}`; + }_${updated}`; obj.tmp_sort_2 = `${obj.group ?? ''}_${obj.priority ? '1' : '0'}_${ sort_val - }_${obj.updated_on}_${obj.created_on}`; + }_${obj.updated_on ?? ''}_${obj.created_on ?? ''}`; return obj; } diff --git a/src/lib/ae_posts/ae_posts__post_comment.ts b/src/lib/ae_posts/ae_posts__post_comment.ts index 4ebbc3a4..b6f70e23 100644 --- a/src/lib/ae_posts/ae_posts__post_comment.ts +++ b/src/lib/ae_posts/ae_posts__post_comment.ts @@ -366,12 +366,13 @@ export async function process_ae_obj__post_comment_props({ log_lvl, specific_processor: (obj) => { const sort_val = (obj.sort ?? 0).toString().padStart(3, '0'); + const updated = obj.updated_on ?? obj.created_on ?? new Date(0).toISOString(); obj.tmp_sort_1 = `${obj.group ?? ''}_${obj.priority ? '1' : '0'}_${ sort_val - }_${obj.updated_on ?? obj.created_on}`; + }_${updated}`; obj.tmp_sort_2 = `${obj.group ?? ''}_${obj.priority ? '1' : '0'}_${ sort_val - }_${obj.updated_on}_${obj.created_on}`; + }_${obj.updated_on ?? ''}_${obj.created_on ?? ''}`; return obj; }