docmd icon indicating copy to clipboard operation
docmd copied to clipboard

[Bug]: Logo link goes stale after SPA navigation and points to the current page

Open celuchmarek opened this issue 1 month ago • 2 comments

docmd version

0.9.8

Node.js version

v25.2.1

OS/Browser

macOS / Chrome

Description

With layout.spa: true, the sidebar logo keeps the relative href of the first page the visitor opened. The template builds it with buildRelativeUrl('/') (packages/ui/templates/layout.ejs:119), so it is ./ on the home page and ../ on /guide/.

On SPA navigation, navigateTo in packages/ui/assets/js/docmd-main.js swaps the content and re-resolves the .sidebar-nav links (line 967). .sidebar-header is not swapped or re-resolved, so the logo keeps ./, which the browser now resolves against the new URL. The logo then links to the current page: the first click only reloads it, the second goes home.

When no logo is set, the site title link (layout.ejs:135) is built the same way.

Steps to Reproduce

  1. A site with logo configured and layout.spa: true.
  2. Open the home page /.
  3. Click a page in the sidebar, e.g. /guide/.
  4. The logo now links to /guide/. Clicking it reloads /guide/; clicking it again opens /.

Expected Behavior

The logo always links to the home page (or to logo.href).

A possible fix: in navigateTo, re-resolve the .sidebar-header a hrefs against data.finalUrl, the same way as the sidebar links. As a workaround we use a customJs file that makes the logo link absolute on load.

celuchmarek avatar Oct 18 '26 10:10 celuchmarek

Resolved in v0.9.9.

The SPA router navigation lifecycle now re-evaluates and dynamically preserves the #site-logo a root href on page transitions, ensuring the logo always reliably links back to the documentation home page regardless of navigation history depth.

Verified with integration contract tests in tests/cli-contracts/url-routing.test.js.

Give it a try.

mgks avatar Nov 03 '26 17:11 mgks

Thanks, works like a charm!

celuchmarek avatar Nov 04 '26 16:11 celuchmarek