Skip to content

Commit f0f491e

Browse files
author
Ajay kumar
committed
[Tech] [Ajay]: Add pre-rendering
1 parent 6a2c350 commit f0f491e

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

TestArena/Blog/Common/GithubGistSnippet.razor.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,16 @@ public class GithubGistSnippetBase : ComponentBase, IAsyncDisposable
1515
[Parameter, EditorRequired] public string UserId { get; set; } = default!;
1616
[Parameter, EditorRequired] public string FileName { get; set; } = default!;
1717

18-
protected override async Task OnInitializedAsync()
18+
protected override async Task OnAfterRenderAsync(bool firstRender)
1919
{
20-
module = await JSRuntime.InvokeAsync<IJSObjectReference>("import", "./js/githubgist.js");
20+
if (firstRender)
21+
{
22+
module = await JSRuntime.InvokeAsync<IJSObjectReference>("import", "./githubgist.js");
23+
24+
await module.InvokeVoidAsync("printSnippetFrom", Id, UserId, FileName);
2125

22-
await module.InvokeVoidAsync("printSnippetFrom", Id, UserId, FileName);
26+
StateHasChanged();
27+
}
2328
}
2429

2530
async ValueTask IAsyncDisposable.DisposeAsync()

TestArena/Blog/IntegrationTesting/Intro/Index.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
@using TestArena.Blog.Common.NavigationUtils
44

55
@code{
6-
PageInfo currentPage = SiteMap.Pages.FirstOrDefault(x => x.RelativePath == "/blog/integration-testing-in-dotnet-intro");
6+
PageInfo currentPage = SiteMap.Pages.FirstOrDefault(x => x.RelativePath == "/blog/integration-testing-in-dotnet-intro")!;
77
}
88

99
<BlogContainer>

TestArena/TestArena.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
</PropertyGroup>
1616

1717
<ItemGroup>
18+
<PackageReference Include="BlazorWasmPreRendering.Build" Version="5.0.1" />
1819
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.14" />
1920
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="9.0.3" PrivateAssets="all" />
2021
<PackageReference Include="PublishSPAforGitHubPages.Build" Version="3.0.0" />

0 commit comments

Comments
 (0)