mirror of
https://github.com/PacktPublishing/Web-Development-with-Blazor-Second-Edition.git
synced 2025-12-06 05:32:03 +01:00
40 lines
1.2 KiB
Plaintext
40 lines
1.2 KiB
Plaintext
|
|
@page "/post/{BlogPostId}"
|
||
|
|
@inject IBlogApi _api
|
||
|
|
@inject NavigationManager _navman
|
||
|
|
@using Markdig;
|
||
|
|
@if (BlogPost != null)
|
||
|
|
{
|
||
|
|
<PageTitle>@BlogPost.Title</PageTitle>
|
||
|
|
<HeadContent>
|
||
|
|
<meta property="og:title" content="@BlogPost.Title" />
|
||
|
|
<meta property="og:description" content="@(new string(BlogPost.Text.Take(100).ToArray()))" />
|
||
|
|
<meta property="og:image" content="@($"{_navman.BaseUri}/pathtoanimage.png")" />
|
||
|
|
<meta property="og:url" content="@_navman.Uri" />
|
||
|
|
<meta name="twitter:card" content="@(new string(BlogPost.Text.Take(100).ToArray()))" />
|
||
|
|
</HeadContent>
|
||
|
|
|
||
|
|
<h2>@BlogPost.Title</h2>
|
||
|
|
@((MarkupString)Markdig.Markdown.ToHtml(BlogPost.Text, pipeline))
|
||
|
|
}
|
||
|
|
|
||
|
|
@code {
|
||
|
|
[Parameter]
|
||
|
|
public string BlogPostId { get; set; } = default!;
|
||
|
|
|
||
|
|
public BlogPost? BlogPost { get; set; }
|
||
|
|
protected async override Task OnParametersSetAsync()
|
||
|
|
{
|
||
|
|
BlogPost = await _api.GetBlogPostAsync(BlogPostId);
|
||
|
|
await base.OnParametersSetAsync();
|
||
|
|
}
|
||
|
|
MarkdownPipeline pipeline;
|
||
|
|
protected override Task OnInitializedAsync()
|
||
|
|
{
|
||
|
|
pipeline = new MarkdownPipelineBuilder()
|
||
|
|
.UseEmojiAndSmiley()
|
||
|
|
.Build();
|
||
|
|
return base.OnInitializedAsync();
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|