docsy icon indicating copy to clipboard operation
docsy copied to clipboard

Language menu in side nav: paths default to locale homepage not translations of current page

Open chalin opened this issue 1 year ago • 3 comments

Consider https://opentelemetry.io/docs/what-is-opentelemetry/, the top-nav language dropdown menu is:

<ul class="dropdown-menu">
  <li><a class="dropdown-item" href="/pt/docs/what-is-opentelemetry/">Português</a></li>
  <li><a class="dropdown-item" href="/ja/docs/what-is-opentelemetry/">日本語 (Japanese)</a></li>
  <li><a class="dropdown-item" href="/fr/docs/what-is-opentelemetry/">Français</a></li>
  <li><a class="dropdown-item" href="/es/docs/what-is-opentelemetry/">Español</a></li>
  <li><a class="dropdown-item" href="/zh/docs/what-is-opentelemetry/">中文 (Chinese)</a></li>
</ul>

The same menu on mobile, which appears in the side-nav under the hamburger, is like this when sidebar_cache_limit is set to a very low number, like 1:

<ul class="dropdown-menu">
  <li><a class="dropdown-item" href="/fr/docs/">Français</a></li>
  <li><a class="dropdown-item" href="/es/docs/">Español</a></li>
  <li><a class="dropdown-item" href="/pt/docs/">Português</a></li>
  <li><a class="dropdown-item" href="/ja/docs/">日本語 (Japanese)</a></li>
  <li><a class="dropdown-item" href="/zh/docs/">中文 (Chinese)</a></li>
</ul>

Notice that the paths all point to the locale's landing page. It might have to do with caching of partials?

/cc @svrnm @theletterf

chalin avatar Nov 20 '24 16:11 chalin

For the record, the paths are correct (refer to translations of the current page) for the Kubernetes website. But they've implemented their own mobile-only hamburger for the top-nav: e.g., visit https://kubernetes.io/docs/concepts/ on mobile (page source). /cc @sftim

chalin avatar Nov 20 '24 16:11 chalin

Just so folks know, that "hamburger" menu predates Kubernetes switching to Docsy.

sftim avatar Nov 20 '24 16:11 sftim

Also also, partials are cached per localization in Hugo.

sftim avatar Nov 20 '24 16:11 sftim