コード例 #1
0
 public static List<TagModel> GetBlogTags()
 {
     ILocator postLocator = new PostLocator();
     var posts = postLocator.GetPosts(PathProvider.GetPostsPath());
     var allTags = posts.SelectMany(p => p.Tags).ToList().Distinct();
     return allTags.Select(t => new TagModel { TagText = t, TagSlug = string.Format("{0}/tag/{1}", Constants.BlogBasePath, UrlGenerator.UrlFriendly(t)) }).ToList();
 }
コード例 #2
0
 public static List<MonthYearModel> GetBlogArchives()
 {
     ILocator postLocator = new PostLocator();
     var posts = postLocator.GetPosts(PathProvider.GetPostsPath());
     var group = posts.GroupBy(p => new {p.DateCreated.Year, p.DateCreated.Month})
                      .OrderByDescending(g => g.Key.Year)
                      .ThenByDescending(g => g.Key.Month);
     return @group.Select(g => new MonthYearModel { MonthYear = string.Format("{0} {1}", GetMonthName(g.Key.Month), g.Key.Year), 
                                                    Slug = string.Format("{0}/{1}/{2}", Constants.BlogBasePath, g.Key.Year, g.Key.Month.ToString("00"))})
                  .ToList();
 }