You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sedona.apache.org by ji...@apache.org on 2026/05/11 03:26:45 UTC

(sedona) branch master updated: [GH-2867] Strip mike canonical-version prefix from language switcher links (#2945)

This is an automated email from the ASF dual-hosted git repository.

jiayuasu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sedona.git


The following commit(s) were added to refs/heads/master by this push:
     new c67892ab95 [GH-2867] Strip mike canonical-version prefix from language switcher links (#2945)
c67892ab95 is described below

commit c67892ab95a88d71766c75793aa3760ad33a889e
Author: Jia Yu <ji...@apache.org>
AuthorDate: Sun May 10 20:26:40 2026 -0700

    [GH-2867] Strip mike canonical-version prefix from language switcher links (#2945)
---
 docs-overrides/partials/alternate.html | 25 ++++++++++++++++++-------
 1 file changed, 18 insertions(+), 7 deletions(-)

diff --git a/docs-overrides/partials/alternate.html b/docs-overrides/partials/alternate.html
index 0056fe9e2c..8e5344b9ab 100644
--- a/docs-overrides/partials/alternate.html
+++ b/docs-overrides/partials/alternate.html
@@ -5,16 +5,27 @@
   </summary>
   <ul class="sd-lang-switch__menu">
     {#-
-      mkdocs-static-i18n stores `alt.link` as a server-absolute path like
-      `/zh/sedonaspark/`. Passing that directly to `| url` keeps the leading
-      slash, so the link bypasses any deployment prefix added by mike (e.g.
-      `/latest-snapshot/`) and lands at the wrong version. Strip the leading
-      slash so `| url` resolves against the docs root and stays inside the
-      current mike version.
+      mkdocs-static-i18n derives `alt.link` from `urlsplit(site_url).path`, so
+      when mike rewrites site_url to include its canonical_version (e.g.
+      `https://sedona.apache.org/latest`) the alt links get that prefix baked
+      in — yielding paths like `/latest/zh/sedonaspark/`. Feeding that through
+      `| url` from a different mike alias (`/latest-snapshot/`) produces
+      broken targets like `/latest-snapshot/latest/zh/`. Strip the mike
+      canonical prefix, then any remaining leading slash, so `| url`
+      resolves against the docs root of the version actually being served.
     -#}
+    {%- set mike_prefix = '' -%}
+    {%- if 'mike' in config.plugins and config.plugins.mike.config.canonical_version -%}
+      {%- set mike_prefix = '/' ~ config.plugins.mike.config.canonical_version ~ '/' -%}
+    {%- endif -%}
     {% for alt in config.extra.alternate %}
       {%- set is_active = (alt.lang == config.theme.language) -%}
-      {%- set alt_link = alt.link[1:] if alt.link.startswith('/') else alt.link -%}
+      {%- set alt_link = alt.link -%}
+      {%- if mike_prefix and alt_link.startswith(mike_prefix) -%}
+        {%- set alt_link = alt_link[mike_prefix|length:] -%}
+      {%- elif alt_link.startswith('/') -%}
+        {%- set alt_link = alt_link[1:] -%}
+      {%- endif -%}
       <li>
         <a
           href="{{ alt_link | url }}"