File tree Expand file tree Collapse file tree 3 files changed +17
-1
lines changed
src/LinkDotNet.Blog.Web/Features
tests/LinkDotNet.Blog.UnitTests/Web/Features/Components Expand file tree Collapse file tree 3 files changed +17
-1
lines changed Original file line number Diff line number Diff line change 2
2
3
3
<HeadContent >
4
4
<meta name =" title" property =" og:title" content =" @Title" />
5
+ <link rel =" canonical" href =" @NavigationManager.Uri" />
5
6
@if (AbsolutePreviewImageUrl != null )
6
7
{
7
8
<meta name =" image" property =" og:image" content =" @AbsolutePreviewImageUrl" />
Original file line number Diff line number Diff line change 22
22
<li class =" nav-item" ><a class =" nav-link" href =" logout?redirectUri=@CurrentUri" ><i class =" lock" ></i > Log out</a ></li >
23
23
</Authorized >
24
24
<NotAuthorized >
25
- <li class =" nav-item" ><a class =" nav-link" href =" login?redirectUri=@CurrentUri" ><i class =" unlocked" ></i > Log in</a ></li >
25
+ <li class =" nav-item" ><a class =" nav-link" href =" login?redirectUri=@CurrentUri" rel = " nofollow " ><i class =" unlocked" ></i > Log in</a ></li >
26
26
</NotAuthorized >
27
27
</AuthorizeView >
28
28
Original file line number Diff line number Diff line change 1
1
using System . Linq ;
2
2
using AngleSharp . Html . Dom ;
3
3
using LinkDotNet . Blog . Web . Features . Components ;
4
+ using Microsoft . AspNetCore . Components ;
4
5
using Microsoft . AspNetCore . Components . Web ;
6
+ using Microsoft . Extensions . DependencyInjection ;
5
7
6
8
namespace LinkDotNet . Blog . UnitTests . Web . Features . Components ;
7
9
@@ -37,6 +39,19 @@ public void ShouldNotSetMetaInformationWhenNotProvided()
37
39
GetMetaTagExists ( cut , "description" ) . Should ( ) . BeFalse ( ) ;
38
40
}
39
41
42
+ [ Fact ]
43
+ public void ShouldSetCanoncialLink ( )
44
+ {
45
+ ComponentFactories . AddStub < HeadContent > ( ps => ps . Get ( p => p . ChildContent ) ) ;
46
+
47
+ var cut = RenderComponent < OgData > ( p => p
48
+ . Add ( s => s . Title , "Title" ) ) ;
49
+
50
+ var link = cut . FindAll ( "link" ) . FirstOrDefault ( l => l . Attributes . Any ( a => a . Name == "rel" && a . Value == "canonical" ) ) as IHtmlLinkElement ;
51
+ var expectedUri = Services . GetRequiredService < NavigationManager > ( ) . Uri ;
52
+ link . Href . Should ( ) . Be ( expectedUri ) ;
53
+ }
54
+
40
55
private static void AssertMetaTagExistsWithValue (
41
56
IRenderedFragment cut ,
42
57
string metaTag ,
You can’t perform that action at this time.
0 commit comments