File tree Expand file tree Collapse file tree 3 files changed +34
-1
lines changed
LinkDotNet.Blog.IntegrationTests/Web/Pages Expand file tree Collapse file tree 3 files changed +34
-1
lines changed Original file line number Diff line number Diff line change @@ -63,5 +63,24 @@ public async Task ShouldSubtractLikeOnEvent()
63
63
var fromDb = await DbContext . BlogPosts . AsNoTracking ( ) . SingleAsync ( d => d . Id == publishedPost . Id ) ;
64
64
fromDb . Likes . Should ( ) . Be ( 1 ) ;
65
65
}
66
+
67
+ [ Fact ]
68
+ public async Task ShouldSetTagsWhenAvailable ( )
69
+ {
70
+ var publishedPost = new BlogPostBuilder ( ) . IsPublished ( ) . WithTags ( "Tag1,Tag2" ) . Build ( ) ;
71
+ await BlogPostRepository . StoreAsync ( publishedPost ) ;
72
+ using var ctx = new TestContext ( ) ;
73
+ ctx . JSInterop . Mode = JSRuntimeMode . Loose ;
74
+ ctx . AddTestAuthorization ( ) ;
75
+ ctx . Services . AddScoped < IRepository > ( _ => BlogPostRepository ) ;
76
+ ctx . Services . AddScoped ( _ => new Mock < ILocalStorageService > ( ) . Object ) ;
77
+ ctx . Services . AddScoped ( _ => new Mock < IToastService > ( ) . Object ) ;
78
+ var cut = ctx . RenderComponent < BlogPostPage > (
79
+ p => p . Add ( b => b . BlogPostId , publishedPost . Id ) ) ;
80
+
81
+ var ogData = cut . FindComponent < OgData > ( ) ;
82
+
83
+ ogData . Instance . Keywords . Should ( ) . Be ( "Tag1,Tag2" ) ;
84
+ }
66
85
}
67
86
}
Original file line number Diff line number Diff line change 14
14
else
15
15
{
16
16
<Title Value =" @BlogPost.Title" ></Title >
17
- <OgData Title =" @BlogPost.Title" AbsolutePreviewImageUrl =" @BlogPost.PreviewImageUrl" Description =" @(Markdown.ToPlainText(BlogPost.ShortDescription))" ></OgData >
17
+ <OgData Title =" @BlogPost.Title"
18
+ AbsolutePreviewImageUrl =" @BlogPost.PreviewImageUrl"
19
+ Description =" @(Markdown.ToPlainText(BlogPost.ShortDescription))"
20
+ Keywords =" @Tags" ></OgData >
18
21
<div class =" blog-outer-box" >
19
22
<div class =" content blog-container" >
20
23
<div class =" blog-content" >
41
44
[Parameter ]
42
45
public string BlogPostId { get ; set ; }
43
46
47
+ private string Tags => BlogPost ? .Tags != null
48
+ ? string .Join (" ," , BlogPost .Tags .Select (b => b .Content ))
49
+ : null ;
50
+
44
51
private BlogPost BlogPost { get ; set ; }
45
52
46
53
protected override async Task OnInitializedAsync ()
Original file line number Diff line number Diff line change 5
5
<Meta name =" image" property =" og:image" content =" @AbsolutePreviewImageUrl" />
6
6
<Meta property =" og:type" content =" article" />
7
7
<Meta property =" og:url" content =" @_navigationManager.Uri" />
8
+ @if (Keywords != null )
9
+ {
10
+ <Meta name =" keywords" content =" @Keywords" />
11
+ }
8
12
@if (Description != null )
9
13
{
10
14
<Meta name =" description" property =" og:description" content =" @Description" />
20
24
21
25
[Parameter ]
22
26
public string Description { get ; set ; }
27
+
28
+ [Parameter ]
29
+ public string Keywords { get ; set ; }
23
30
}
You can’t perform that action at this time.
0 commit comments