diff --git a/src/BlazeKit.Website/Program.cs b/src/BlazeKit.Website/Program.cs index 09eb5ba..dd1629e 100644 --- a/src/BlazeKit.Website/Program.cs +++ b/src/BlazeKit.Website/Program.cs @@ -6,8 +6,15 @@ if (args.Count() > 0 && args[0] == "ssg") { Console.WriteLine("Building Static Site"); + + if(args.Count() < 2) { + Console.WriteLine("SSG Error: No output path provided"); + return; + } + Console.WriteLine($"SSG OUtput: {args[1]}"); + new BlazeKit.Static.StaticSiteGenerator( - Path.Combine(".blazekit","build","ssg"), + args[1], Path.Combine(".blazekit","build","tmp","wwwroot"), typeof(BlazeKit.Website.Index).Assembly ).Build(); diff --git a/src/BlazeKit.Website/Properties/launchSettings.json b/src/BlazeKit.Website/Properties/launchSettings.json index b79b18b..1b1e970 100644 --- a/src/BlazeKit.Website/Properties/launchSettings.json +++ b/src/BlazeKit.Website/Properties/launchSettings.json @@ -19,6 +19,17 @@ "ASPNETCORE_ENVIRONMENT": "Development" } }, + "SSG": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", + "applicationUrl": "http://localhost:5000", + "commandLineArgs": "ssg ../../.vercel/output/static", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, "https": { "commandName": "Project", "dotnetRunMessages": true, diff --git a/src/BlazeKit.Website/Routes/(Public)/Items/Details/[Id]/Page.razor b/src/BlazeKit.Website/Routes/(Public)/Items/Details/[Id]/Page.razor deleted file mode 100644 index 481d5cf..0000000 --- a/src/BlazeKit.Website/Routes/(Public)/Items/Details/[Id]/Page.razor +++ /dev/null @@ -1,93 +0,0 @@ -@using BlazeKit.Reactivity.Signals; -@using BlazeKit.Reactivity -@using BlazeKit.Reactivity.Blazor; -@using System.Text.Json.Nodes; - -@code { - - // Defice a record type for the api response - record Person(string name); - - [Inject] - public NavigationManager Router { get; set; } - - private ISignal person; - private ISignal computed; - private ISignal loading; - public Page() - { - - } - protected async override Task OnInitializedAsync() - { - this.loading = State.New(true, this); - person = Signal.New(new Person("")); - computed = Derived.New(() => - { - Console.WriteLine($"Persons Name: {person.Value.name}"); - return this.person.Value.name.Length; - },this); - - Console.WriteLine($"Param: '{Id}'"); - - using (var http = new HttpClient()) { - var response = await http.GetStringAsync($"https://swapi.dev/api/people/{Id}"); - var person = System.Text.Json.JsonSerializer.Deserialize(response); - Console.WriteLine($"Fetched Person: {person.name}"); - this.person.Value = person; - } - - this.loading.Value = false; - } - - private void Go() - { - Router.NavigateTo($"/items/details/{Id}", forceLoad: true); - } -} - -BlazeKit - Nested layouts and route parameters -

This route uses nested layouts and auto-generated route parameter.

-

The layout for Pages/(Public)/Items/Details/[Id]/Page.razor is composed from:

-
    -
  • Pages/(Public)/Items/Details/Layout.razor
  • -
  • Pages/(Public)/Items/Layout.razor
  • -
  • Pages/(Public)/Layout.razor
  • -
  • Pages/Layout.razor
  • -
-
-    
-    Pages/
-    │ (Public)/
-    │ ├ Items/
-    │ │ ├ Details/
-    │ │ │  ├ [Id]
-    │ │ │  │ └ Page.razor
-    │ │ │  └ Layout.razor
-    │ │ └ Layout.razor
-    │ └ Layout.razor
-    ├ Page.razor
-    └ Layout.razor
-    
-
- -

Route Param Id: @Id

- -
- - - Navigation is done with forceLoad option from NavigationManager - - -

Name: @person.Value.name

-

Name length: @computed.Value

-
- -

Fetching https://swapi.dev/api/people/@Id .... Please wait 🕐

-
-
-
- - - - diff --git a/src/BlazeKit.Website/Routes/Page.md b/src/BlazeKit.Website/Routes/Page.md index 5e9b257..382b084 100644 --- a/src/BlazeKit.Website/Routes/Page.md +++ b/src/BlazeKit.Website/Routes/Page.md @@ -31,5 +31,4 @@ Are more features coming to BlazeKit? I am certainly like to keep working on BlazeKit since i see some oppertunities with the release of .NET 8. Yes, i am looking at you Server-Side-Rendering. ## Links to Examples -- [Nested Layouts Demo with Route Params](/items/details/2?foo=bar) - [Breaking out of layouts Demo](/items/details) diff --git a/ssg.ps1 b/ssg.ps1 new file mode 100644 index 0000000..5e49c5b --- /dev/null +++ b/ssg.ps1 @@ -0,0 +1,5 @@ +cd ./src/BlazeKit.Website +dotnet publish -o .blazekit/build/tmp +dotnet run ssg ../../.vercel/output/static +cd .. +cd .. diff --git a/ssg.sh b/ssg.sh index fafe404..dd7269a 100644 --- a/ssg.sh +++ b/ssg.sh @@ -1,6 +1,4 @@ #!/usr/bin/env bash cd ./src/BlazeKit.Website /vercel/.dotnet/dotnet publish -o .blazekit/build/tmp -/vercel/.dotnet/dotnet run ssg -mkdir -p ../../.vercel/output/static -rsync -av ./.blazekit/build/ssg/ ./../../.vercel/output/static/ +/vercel/.dotnet/dotnet run ssg ../../.vercel/output/static diff --git a/vercel.json b/vercel.json index 647c374..48685eb 100644 --- a/vercel.json +++ b/vercel.json @@ -1,5 +1,5 @@ { - "buildCommand": "cd ./src/BlazeKit.Website ; /vercel/.dotnet/dotnet publish -o .blazekit/build/tmp ; /vercel/.dotnet/dotnet run ssg ; mkdir -p ../../.vercel/output/static ; cp -r .blazekit/build/ssg/. ../../.vercel/output/static", + "buildCommand": "chmod +x ./ssg.sh ; ./ssg.sh", "installCommand": "chmod +x ./install.sh ; ./install.sh; export DOTNET_ROOT=$HOME/.dotnet ; export PATH=$PATH:$DOTNET_ROOT:$DOTNET_ROOT/tools ; /vercel/.dotnet/dotnet --version", "outputDirectory": ".vercel/output/static", "headers": [