Skip to content

Commit

Permalink
Merge pull request #1235 from hydephp/bugfixes
Browse files Browse the repository at this point in the history
Update MarkdownPost::getLatestPosts helper to sort using the DateTime object timestamp
  • Loading branch information
caendesilva authored Mar 8, 2023
2 parents 66f7c08 + 13f8f45 commit 637b873
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/framework/src/Pages/MarkdownPost.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ class MarkdownPost extends BaseMarkdownPage implements BlogPostSchema
/** @return \Hyde\Foundation\Kernel\PageCollection<\Hyde\Pages\MarkdownPost> */
public static function getLatestPosts(): PageCollection
{
return static::all()->sortByDesc('matter.date');
return static::all()->sortByDesc(function (self $post): int {
return $post->date?->dateTimeObject->getTimestamp() ?? 0;
});
}

public function toArray(): array
Expand Down

0 comments on commit 637b873

Please sign in to comment.