Exemple #1
0
        private async Task <SyndicationFeed> SetupSyndicationFeed()
        {
            // This ID must not change
            const string baseId    = "uuid:b8787de3-c2eb-41bc-89ab-9c176300d44c";
            var          feedItems = await _postService.GetPostsFeedItemsAsync(Url, baseId);

            var siteUri = new Uri(_canonical.CanonicaliseUrl(Url.Action("Index")));

            return(new SyndicationFeed("Matts Blog", string.Empty, siteUri, feedItems)
            {
                Id = baseId
            });
        }
Exemple #2
0
 public async Task <List <SyndicationItem> > GetPostsFeedItemsAsync(IUrlHelper urlHelper, string baseId, int?page = null)
 {
     return((await GetPostsAsync(0, int.MaxValue, allowUnpublished: false))
            .Select(post =>
     {
         var item = new SyndicationItem
         {
             Id = baseId + $";id={post.Id}",
             Title = new TextSyndicationContent(post.Title, TextSyndicationContentKind.Plaintext),
             Content = new TextSyndicationContent(post.ToHtml(), TextSyndicationContentKind.Html),
             PublishDate = new DateTimeOffset(post.Published.Value, TimeSpan.Zero),
             LastUpdatedTime = new DateTimeOffset(post.Published.Value, TimeSpan.Zero),
         };
         item.Links.Add(
             new SyndicationLink(
                 new Uri(_canonical.CanonicaliseUrl(urlHelper.Action("Read", "Journal", new { year = post.Published?.Year, slug = post.Slug })))));
         return item;
     })
            .ToList());
 }