Skip to content

Sidebar links ignore <base href> on sites served from a sub-path #40

Closed

Description

@Shewart

Summary

Sidebar links are rendered root-relative (href="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/docs/introduction"). A root-relative URL ignores <base href>, so a site exported with shelldocs build --base-href /my-repo/ and served from https://user.github.io/my-repo/ links to https://user.github.io/docs/introduction, which is a 404.

Steps to reproduce

  1. shelldocs build --base-href /my-repo/ --output publish
  2. Serve publish/ under /my-repo/ (for example GitHub Pages for a project repo).
  3. Click any sidebar link.

Expected: /my-repo/docs/introduction.
Actual: /docs/introduction (404).

Where

  • src/ShellDocs.Components/Chrome/DocsSidebarNode.razor (href="@Node.Url", href="@_index.Url")
  • Probably the same for breadcrumbs, prev/next, the TOC's page links, package and version selectors and search results. Worth checking every place that renders a NavigationNode.Url.

Suggested fix

Render navigation links base-relative (docs/introduction, no leading slash) so they resolve against <base href>, or prefix them with NavigationManager.BaseUri's path. Add a test that renders the layout and asserts no chrome link starts with /, and check a --base-href export in a browser.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions