Skip to content

fix: 404 for unknown pages, 404.html in static builds, static sidebar collapse (0.1.14-alpha) - #36

Merged
Shewart merged 5 commits into
mainfrom
fix/not-found-and-sidebar-collapse
Oct 10, 2026
Merged

Shewart merged 5 commits into
mainfrom
fix/not-found-and-sidebar-collapse

Conversation

@Shewart

@Shewart Shewart commented Oct 10, 2026

Copy link
Copy Markdown
Contributor

Summary

Unknown docs pages now answer HTTP 404, static exports get a real 404.html, and the desktop sidebar collapse works without a Blazor runtime, so search is the only chrome that still needs one. Bumps to 0.1.14-alpha.

Added

  • <DocsNotFound />, the docs page's not-found view, used by the init template and the example site. It answers 404.
    • The status is set in Response.OnStarting: .NET 10 sends an empty body for a page whose status is already 404, unless the app has a NotFoundPage or status-code re-execution.
    • Path, HomeHref and HomeLabel override the message and the link back. The link defaults to where /docs leads.
  • shelldocs build writes 404.html from the site's own not-found view, for GitHub Pages, Netlify and Cloudflare Pages. --spa-fallback still replaces it with index.html.

Changed

  • Desktop sidebar collapse:
    • The toggle buttons are [data-sidebar-collapse-toggle], handled by shelldocs.js, which flips [data-sidebar-collapsed] on the page shell.
    • The choice is remembered in localStorage and restored before the sidebar can flash open.
    • The docs-sidebar-collapsed class is gone. SidebarCollapseState is still registered but unused.
  • shelldocs build fails on a page that renders as not found, whether it answered 404 or rendered <DocsNotFound>.

Upgrading

  • Replace the not-found branch in DocsPage.razor with <DocsNotFound />.
  • Restyle .docs-sidebar-collapsed as [data-sidebar-collapsed="true"].

Testing

  • Release build 0 warnings; 343 tests pass, 6 new: the 404 timing, the not-found view, the template, build detection, collapse markup and its JS. Each commit builds and passes on its own.
  • Example site, interactive and as a shelldocs build static export:
    • unknown URLs answer 404 with the full layout;
    • collapse and expand are remembered across pages without a server;
    • 404.html is written and renders in the site layout.
  • Pack dry-run: all six packages at 0.1.14-alpha.
  • ShellUI docs site built against main and against this branch: home identical; the other 241 pages differ only by the collapse markup.

The collapse and expand buttons toggled SidebarCollapseState through @OnClick, so they did nothing on a static export. They are now [data-sidebar-collapse-toggle] buttons handled by shelldocs.js, which flips [data-sidebar-collapsed] on the page shell and remembers the choice in localStorage; it's restored as soon as the script runs, so the sidebar doesn't flash open, and again after Blazor swaps the DOM. The expand toolbar is always rendered in the Sidebar layout and shown by CSS. SidebarCollapseState stays registered, unused.
Unknown docs pages rendered "Page not found" with status 200, so search engines indexed them. <DocsNotFound /> renders the not-found view and answers 404. The status is set in Response.OnStarting: .NET 10 sends an empty body for a page whose status is already 404 unless the app has a NotFoundPage or status-code re-execution. Path, HomeHref and HomeLabel override the message and the link back, which defaults to where /docs leads. The init template and the example site use it.
A page that answers 404, or renders <DocsNotFound> with another status, now counts as a prerender failure instead of shipping a "Page not found" page. shelldocs build also requests a URL no site has and, when it renders <DocsNotFound> with a 404, writes it as 404.html for static hosts that serve it (GitHub Pages, Netlify, Cloudflare Pages); --spa-fallback still replaces it with index.html.
CHANGELOG [Unreleased], README, ARCHITECTURE (chrome table, not-found, build steps) and the installation page.
Cuts the Unreleased section as 0.1.14-alpha and records the release in the ROADMAP's hardening list.
@Shewart
Shewart merged commit ee08ce3 into main Oct 10, 2026
1 check passed
@Shewart
Shewart deleted the fix/not-found-and-sidebar-collapse branch October 10, 2026 11:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant