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

lidongdai pushed a commit to branch fix-docs-version-nav-404
in repository https://gitbox.apache.org/repos/asf/seatunnel-website.git

commit 9c5546537de9cc5a95d382f08af5b903a28f4b27
Author: davidzollo <[email protected]>
AuthorDate: Fri Mar 13 11:00:37 2026 +0800

    [Fix] Fix 404 error when navigating to docs version 2.3.13 from navbar
    
    The Document dropdown in navbar hardcoded all version links to
    `docs/{version}/about`, but since version 2.3.13 the docs structure
    was reorganized and the about page moved to `introduction/about`.
    
    This fix adds a `getVersionHomePage()` function that dynamically reads
    each version's sidebar JSON to resolve the correct first document ID,
    so future documentation restructures will be handled automatically
    without requiring code changes.
    
    Co-Authored-By: Claude Opus 4.6 <[email protected]>
---
 docusaurus.config.js | 30 +++++++++++++++++++++++++++++-
 1 file changed, 29 insertions(+), 1 deletion(-)

diff --git a/docusaurus.config.js b/docusaurus.config.js
index c89df8e6a4a0..cc70b1e13f81 100644
--- a/docusaurus.config.js
+++ b/docusaurus.config.js
@@ -5,6 +5,34 @@ const st_web_versions = 
require("./seatunnel_web_versions.json");
 const fs = require("fs");
 const path = require("path");
 
+function getVersionHomePage(version) {
+  const sidebarFile = path.join(
+    __dirname,
+    "versioned_sidebars",
+    `version-${version}-sidebars.json`
+  );
+  if (fs.existsSync(sidebarFile)) {
+    try {
+      const sidebar = JSON.parse(fs.readFileSync(sidebarFile, "utf8"));
+      const docs = sidebar.docs || [];
+      const first = docs[0];
+      if (typeof first === "string") {
+        return first;
+      }
+      if (first && first.type === "category" && Array.isArray(first.items)) {
+        for (const item of first.items) {
+          if (typeof item === "string") {
+            return item;
+          }
+        }
+      }
+    } catch (e) {
+      // fallback to default
+    }
+  }
+  return "about";
+}
+
 function listMarkdownFiles(rootDir) {
   /** @type {string[]} */
   const results = [];
@@ -222,7 +250,7 @@ const config = {
           items: [
             ...versions.slice(0, 5).map((version) => ({
               label: version,
-              to: `docs/${version}/about`
+              to: `docs/${version}/${getVersionHomePage(version)}`
             })),
             {
               label: "Next",

Reply via email to