ssg: StaticSiteClient: GetRecentPosts use StaticSitePost.GetAllPosts

This commit is contained in:
Nick Vella 2019-07-16 15:17:15 +10:00
parent 59808f70da
commit ba971fc2db
1 changed files with 2 additions and 9 deletions

View File

@ -69,15 +69,8 @@ namespace OpenLiveWriter.BlogClient.Clients.StaticSite
/// <param name="now">If null, then includes future posts. If non-null, then only includes posts before the *UTC* 'now' time.</param>
/// <returns></returns>
public BlogPost[] GetRecentPosts(string blogId, int maxPosts, bool includeCategories, DateTime? now) =>
Directory.GetFiles(Path.Combine(Config.LocalSitePath, Config.PostsPath), "*.html")
.Select(postFile =>
{
try
{
return StaticSitePost.LoadFromFile(Path.Combine(Config.LocalSitePath, Config.PostsPath, postFile), Config).BlogPost;
}
catch { return null; }
})
StaticSitePost.GetAllPosts(Config)
.Select(post => post.BlogPost)
.Where(post => post != null && (now == null || post.DatePublished < now))
.OrderByDescending(post => post.DatePublished)
.Take(maxPosts)