Skip to content

Commit 72b98cf

Browse files
committed
Added OG:Description for article itself
1 parent 857b52a commit 72b98cf

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

LinkDotNet.Blog.UnitTests/Web/Shared/Admin/CreateNewBlogPostTests.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,26 @@ public void ShouldFillGivenBlogPost()
5555
blogPostFromComponent.ShortDescription.Should().Be("Desc");
5656
blogPostFromComponent.Content.Should().Be("Content");
5757
}
58+
59+
[Fact]
60+
public void ShouldNotDeleteModelWhenNotSet()
61+
{
62+
using var ctx = new TestContext();
63+
BlogPost blogPost = null;
64+
var cut = ctx.RenderComponent<CreateNewBlogPost>(
65+
p => p.Add(c => c.ClearAfterCreated, false)
66+
.Add(c => c.OnBlogPostCreated, post => blogPost = post));
67+
cut.Find("#title").Change("My Title");
68+
cut.Find("#short").Change("My short Description");
69+
cut.Find("#content").Change("My content");
70+
cut.Find("#preview").Change("My preview url");
71+
cut.Find("#tags").Change("Tag1,Tag2,Tag3");
72+
73+
cut.Find("form").Submit();
74+
75+
cut.
76+
cut.WaitForState(() => blogPost != null);
77+
cut.Find("#title").TextContent.Should().Be("My Title");
78+
}
5879
}
5980
}

LinkDotNet.Blog.Web/Shared/OgData.razor

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
<Meta name="image" property="og:image" content="@PreviewImageUrl" />
66
<Meta property="og:type" content="article" />
77
<Meta property="og:url" content="@_navigationManager.Uri" />
8+
@if (Description != null)
9+
{
10+
<Meta propertty="og:description" content="@Description" />
11+
}
812

913
@code {
1014

@@ -13,5 +17,7 @@
1317

1418
[Parameter]
1519
public string PreviewImageUrl { get; set; }
16-
20+
21+
[Parameter]
22+
public string Description { get; set; }
1723
}

0 commit comments

Comments
 (0)