public Feed(PostsMetadata postsMetadata, HttpContextWrapper contextWrapper) { _site = new Site(); _contextWrapper = contextWrapper; SetupFeed(); AddPostsToFeed(postsMetadata); }
private void AddPostsToFeed(PostsMetadata postsMetadata) { var feedItems = new List<SyndicationItem>(); foreach (var post in postsMetadata.List) { var item = new SyndicationItem { Title = SyndicationContent.CreatePlaintextContent(post.Title), Summary = SyndicationContent.CreatePlaintextContent(post.ShortDescription) }; if (post.PublishDate != DateTime.MinValue) item.PublishDate = post.PublishDate; if (post.LastUpdatedDate != DateTime.MinValue) item.LastUpdatedTime = post.LastUpdatedDate; else if (post.LastUpdatedDate == DateTime.MinValue && post.PublishDate != DateTime.MinValue) item.LastUpdatedTime = post.PublishDate; item.Links.Add(SyndicationLink.CreateSelfLink(_contextWrapper.GetAbsoluteUrl("~/blog/" + post.Slug))); item.Authors.Add(new SyndicationPerson { Name = post.Author }); feedItems.Add(item); } _feed.Items = feedItems; }
public Post(string postName, PostsMetadata metadataInstance) { _contentItem = new ContentItem(postName, PostsMetadata.PostsRoot, metadataInstance.List); }