ssg: StaticSiteClient: GetRecentPosts use StaticSitePost.GetAllPosts
This commit is contained in:
parent
59808f70da
commit
ba971fc2db
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue