Exemplo n.º 1
0
 /// <summary>
 /// Returns recent posts
 /// </summary>
 /// <param name="blogId"></param>
 /// <param name="maxPosts"></param>
 /// <param name="includeCategories"></param>
 /// <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) =>
 StaticSitePost.GetAllPosts(Config, true)
 .Select(post => post.BlogPost)
 .Where(post => post != null && (now == null || post.DatePublished < now))
 .OrderByDescending(post => post.DatePublished)
 .Take(maxPosts)
 .ToArray();
Exemplo n.º 2
0
 public BlogPostCategory[] GetCategories(string blogId) =>
 StaticSitePost.GetAllPosts(Config, false)
 .SelectMany(post => post.BlogPost.Categories.Select(cat => cat.Name))
 .Distinct()
 .Select(cat => new BlogPostCategory(cat))
 .ToArray();