Skip to content

Commit

Permalink
Merge pull request #4 from koeeenig/fix-vercel-url-rewrite
Browse files Browse the repository at this point in the history
Fixes Vercel Rewrites for SPA
  • Loading branch information
koeeenig committed Nov 19, 2023
2 parents 0467f70 + aeeb2ae commit f449a1d
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 19 deletions.
42 changes: 24 additions & 18 deletions src/BlazeKit.Site/Pages/Reactivity/Basic/Page.razor
Original file line number Diff line number Diff line change
Expand Up @@ -123,24 +123,30 @@
<pre>
<code class="language-cshtml-razor">
@@code {
// Create a Signal
@AsHtml("ISignal<int> counter = new BlzState<int>(0, this)").Value
@AsHtml(@"// Create a derived State
ISignal<int> doubled =
new Derived<int>(
() => counter.Value * 2,
this
);").Value
@AsHtml(@"// Create an Effect
new Effect(() => {
if(counter.Value > 0 && counter.Value % 5 == 0)
{
// since booms in not a signal, we need to notify the UI manually
// this is required if the counter updates in background task
booms++;
}
}
);").Value
@AsHtml(@"protected override void OnInitialized()
{
// Create a Signal
this.counter = new State<int>(0, this);
// Create a derived State
this.doubled =
new Derived<int>(
() => counter.Value * 2,
this
);
// Create an Effect
this.sideEffect =
new Effect(() =>
{
if(counter.Value > 0 && counter.Value % 2 == 0)
{
// since booms in not a signal, we need to notify the UI manually
// this is required if the counter updates in background task
booms++;
InvokeAsync(StateHasChanged);
}
}
);
}").Value
}

@AsHtml("<p>@counter.Value</p>").Value
Expand Down
8 changes: 7 additions & 1 deletion vercel.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
{
"buildCommand": "dotnet build ; dotnet publish ./src/BlazeKit.Site",
"installCommand": "rpm -Uvh https://packages.microsoft.com/config/centos/7/packages-microsoft-prod.rpm ; yum -y install dotnet-sdk-7.0 ; dotnet --version",
"outputDirectory": ".vercel/output/static"
"outputDirectory": ".vercel/output/static",
"rewrites": [
{
"source": "/(.*)",
"destination": "/index.html"
}
]
}

0 comments on commit f449a1d

Please sign in to comment.