-
-
Notifications
You must be signed in to change notification settings - Fork 93
Expand file tree
/
Copy pathOgData.razor
More file actions
58 lines (47 loc) · 1.44 KB
/
Copy pathOgData.razor
File metadata and controls
58 lines (47 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
@using System.IO
@inject NavigationManager NavigationManager
<HeadContent>
<meta name="title" property="og:title" content="@Title" />
<link rel="canonical" href="@GetCanoncialUri()" />
@if (AbsolutePreviewImageUrl is not null)
{
<meta name="image" property="og:image" content="@AbsolutePreviewImageUrl"/>
}
<meta property="og:type" content="article" />
<meta property="og:url" content="@NavigationManager.Uri" />
@if (Keywords is not null)
{
<meta name="keywords" content="@Keywords"/>
}
@if (Description is not null)
{
<meta name="description" property="og:description" content="@Description" />
}
@if (ChildContent is not null)
{
@ChildContent
}
</HeadContent>
@code {
[Parameter, EditorRequired]
public required string Title { get; set; }
[Parameter]
public string? AbsolutePreviewImageUrl { get; set; }
[Parameter]
public string? Description { get; set; }
[Parameter]
public string? Keywords { get; set; }
[Parameter]
public string? CanonicalRelativeUrl { get; set; }
[Parameter]
public RenderFragment? ChildContent { get; set; }
private string GetCanoncialUri()
{
if (!string.IsNullOrEmpty(CanonicalRelativeUrl))
{
return Path.Combine(NavigationManager.BaseUri, CanonicalRelativeUrl);
}
var uri = new Uri(NavigationManager.Uri);
return uri.GetLeftPart(UriPartial.Path);
}
}