Skip to content

Commit b3bfce6

Browse files
committed
Add preview image
1 parent 9c3a22f commit b3bfce6

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/LinkDotNet.Blog.Web/Controller/RssFeedController.cs

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.Text;
66
using System.Threading.Tasks;
77
using System.Xml;
8+
using System.Xml.Linq;
89
using LinkDotNet.Blog.Domain;
910
using LinkDotNet.Blog.Infrastructure.Persistence;
1011
using Microsoft.AspNetCore.Mvc;
@@ -62,6 +63,7 @@ private async Task<List<SyndicationItem>> GetBlogPostItems(string url)
6263
{
6364
PublishDate = blogPost.UpdatedDate,
6465
LastUpdatedTime = blogPost.UpdatedDate,
66+
ElementExtensions = { new XElement("image", blogPost.PreviewImageUrl) },
6567
};
6668
blogPostItems.Add(item);
6769
}

tests/LinkDotNet.Blog.IntegrationTests/Web/Controller/RssFeedControllerTests.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,14 @@ public async Task ShouldCreateRssFeed()
3737
var blogPost1 = new BlogPostBuilder()
3838
.WithTitle("1")
3939
.WithShortDescription("Short 1")
40+
.WithPreviewImageUrl("preview1")
4041
.WithUpdatedDate(new DateTime(2022, 5, 1))
4142
.Build();
4243
blogPost1.Id = "1";
4344
var blogPost2 = new BlogPostBuilder()
4445
.WithTitle("2")
4546
.WithShortDescription("Short 2")
47+
.WithPreviewImageUrl("preview2")
4648
.WithUpdatedDate(new DateTime(2022, 6, 1))
4749
.Build();
4850
blogPost2.Id = "2";
@@ -57,6 +59,6 @@ public async Task ShouldCreateRssFeed()
5759

5860
xml.Should().NotBeNull();
5961
var content = Encoding.UTF8.GetString(xml.FileContents);
60-
content.Should().Contain("<rss\r\n version=\"2.0\">\r\n <channel>\r\n <title>Test</title>\r\n <link>http://localhost/</link>\r\n <description>Description</description>\r\n <item>\r\n <guid\r\n isPermaLink=\"false\">2</guid>\r\n <link>http://localhost//blogPost/2</link>\r\n <title>2</title>\r\n <description>Short 2</description>\r\n <pubDate>Wed, 01 Jun 2022 00:00:00 +0200</pubDate>\r\n </item>\r\n <item>\r\n <guid\r\n isPermaLink=\"false\">1</guid>\r\n <link>http://localhost//blogPost/1</link>\r\n <title>1</title>\r\n <description>Short 1</description>\r\n <pubDate>Sun, 01 May 2022 00:00:00 +0200</pubDate>\r\n </item>\r\n </channel>\r\n</rss>");
62+
content.Should().Contain("<rss\r\n version=\"2.0\">\r\n <channel>\r\n <title>Test</title>\r\n <link>http://localhost/</link>\r\n <description>Description</description>\r\n <item>\r\n <guid\r\n isPermaLink=\"false\">2</guid>\r\n <link>http://localhost//blogPost/2</link>\r\n <title>2</title>\r\n <description>Short 2</description>\r\n <pubDate>Wed, 01 Jun 2022 00:00:00 +0200</pubDate>\r\n <image>preview2</image>\r\n </item>\r\n <item>\r\n <guid\r\n isPermaLink=\"false\">1</guid>\r\n <link>http://localhost//blogPost/1</link>\r\n <title>1</title>\r\n <description>Short 1</description>\r\n <pubDate>Sun, 01 May 2022 00:00:00 +0200</pubDate>\r\n <image>preview1</image>\r\n </item>\r\n </channel>\r\n</rss>");
6163
}
6264
}

0 commit comments

Comments
 (0)