Skip to content

Commit 637b873

Browse files
authored
Merge pull request #1235 from hydephp/bugfixes
Update MarkdownPost::getLatestPosts helper to sort using the DateTime object timestamp
2 parents 66f7c08 + 13f8f45 commit 637b873

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

packages/framework/src/Pages/MarkdownPost.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ class MarkdownPost extends BaseMarkdownPage implements BlogPostSchema
3535
/** @return \Hyde\Foundation\Kernel\PageCollection<\Hyde\Pages\MarkdownPost> */
3636
public static function getLatestPosts(): PageCollection
3737
{
38-
return static::all()->sortByDesc('matter.date');
38+
return static::all()->sortByDesc(function (self $post): int {
39+
return $post->date?->dateTimeObject->getTimestamp() ?? 0;
40+
});
3941
}
4042

4143
public function toArray(): array

0 commit comments

Comments
 (0)