Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ jobs:
uses: actions/setup-dotnet@v1
with:
dotnet-version: 9.0.x
- name: .NET WASM Workload
run: dotnet workload install wasm-tools
- name: Publish with dotnet
run: dotnet publish ./src --configuration Release --output build
run: dotnet publish ./src/GIB --configuration Release --output build
- name: Deploy to Github Pages
uses: JamesIves/github-pages-deploy-action@releases/v3
with:
Expand Down
7 changes: 6 additions & 1 deletion src/GIB/GIB.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,18 @@
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<BlazorWasmPrerenderingDeleteLoadingContents>true</BlazorWasmPrerenderingDeleteLoadingContents>
<BlazorWasmPrerenderingMode>WebAssemblyPrerendered</BlazorWasmPrerenderingMode>
<GHPages>true</GHPages>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Blazored.LocalStorage" Version="4.5.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="9.0.8" />
<PackageReference Include="BlazorWasmPreRendering.Build" Version="6.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="9.0.8" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="9.0.8" PrivateAssets="all" />
<PackageReference Include="MudBlazor" Version="7.9.0" />
<PackageReference Include="PublishSPAforGitHubPages.Build" Version="3.0.1" />
</ItemGroup>

</Project>
26 changes: 20 additions & 6 deletions src/GIB/Program.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,30 @@
using Blazored.LocalStorage;
using GIB;
using Microsoft.AspNetCore.Components.Web;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using MudBlazor.Services;

var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add<GIB.App>("#app");
builder.RootComponents.Add<HeadOutlet>("head::after");

builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });
// Determine whether root components are already registered via prerednered HTML contents.
// See https://github.com/jsakamoto/BlazorWasmPreRendering.Build
if (!builder.RootComponents.Any())
{
builder.RootComponents.Add<App>("#app");
builder.RootComponents.Add<HeadOutlet>("head::after");
}

builder.Services.AddMudServices();

builder.Services.AddBlazoredLocalStorage();
// Do not change this line, it's for prerendering. See https://github.com/jsakamoto/BlazorWasmPreRendering.Build
ConfigureServices(builder.Services, builder.HostEnvironment.BaseAddress, builder.Configuration);

await builder.Build().RunAsync();

// This method signature follows a convention to enable prerendering.
// See https://github.com/jsakamoto/BlazorWasmPreRendering.Build
static void ConfigureServices(IServiceCollection services, string baseAddress, IConfiguration configuration)
{
services
.AddScoped(sp => new HttpClient { BaseAddress = new Uri(baseAddress) })
.AddMudServices()
.AddBlazoredLocalStorage();
}
11 changes: 1 addition & 10 deletions src/GIB/wwwroot/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,7 @@
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Gradudated Income Boost</title>

<!-- Adapted from https://stackoverflow.com/a/69769086/8435941 -->
<script>
var baseTag = document.createElement("base");
var appRoot = "/gib/";
var path = document.location.pathname;
baseTag.href = (path.indexOf(appRoot) === 0 || path + "/" === appRoot) ? appRoot : "/";
document.head.appendChild(baseTag);
</script>

<base href="/" />
<link rel="stylesheet" href="css/app.css" />
<link rel="icon" type="image/png" href="favicon.png" />
<link href="GIB.styles.css" rel="stylesheet" />
Expand Down