@@ -25,39 +25,26 @@ jobs:
2525 steps :
2626 - uses : actions/checkout@v4
2727
28+ - name : Configure Pages
29+ uses : actions/configure-pages@v5
30+
2831 - name : Setup .NET
2932 uses : actions/setup-dotnet@v4
3033 with :
3134 dotnet-version : 10.0.x
3235
3336 - name : Publish SimpleCanvas (Release)
34- run : dotnet publish "BlazorCanvas2d.Samples/BlazorCanvas2d.Samples.SimpleCanvas/BlazorCanvas2d.Samples.SimpleCanvas.csproj" -c Release -o "artifacts/publish"
37+ run : dotnet publish "BlazorCanvas2d.Samples/BlazorCanvas2d.Samples.SimpleCanvas/BlazorCanvas2d.Samples.SimpleCanvas.csproj" -c Release -o "artifacts/publish" -p:BaseHref="/${{ github.event.repository.name }}/"
3538
3639 - name : Prepare GitHub Pages assets
3740 shell : bash
3841 run : |
3942 set -euo pipefail
4043 WWWROOT="artifacts/publish/wwwroot"
41- REPO_NAME="${GITHUB_REPOSITORY#*/}"
42- BASE_HREF="/${REPO_NAME}/"
43-
44- # Blazor WASM needs correct base href when hosted from /<repo>/
45- python3 - <<'PY'
46- import os
47- import pathlib
48- import re
49-
50- wwwroot = pathlib.Path(os.environ["WWWROOT"])
51- base_href = os.environ["BASE_HREF"]
52- index = wwwroot / "index.html"
53- html = index.read_text(encoding="utf-8")
54- html2, n = re.subn(r'<base href="[^"]*"\s*/>', f'<base href="{base_href}" />', html, count=1)
55- if n != 1:
56- raise SystemExit("Expected exactly one <base href=\"...\" /> in index.html")
57- index.write_text(html2, encoding="utf-8")
58- (wwwroot / "404.html").write_text(html2, encoding="utf-8")
59- (wwwroot / ".nojekyll").write_text("", encoding="utf-8")
60- PY
44+ # Ensure SPA fallback works for GitHub Pages (client-side routing)
45+ cp "${WWWROOT}/index.html" "${WWWROOT}/404.html"
46+ # Avoid Pages attempting to run Jekyll processing
47+ : > "${WWWROOT}/.nojekyll"
6148
6249 - name : Upload Pages artifact
6350 uses : actions/upload-pages-artifact@v3
0 commit comments