From 345bdc305853d21e4e4ffc8e51bfcdfd27aa54a6 Mon Sep 17 00:00:00 2001 From: Jason Stirnaman Date: Fri, 6 Feb 2026 11:15:09 -0600 Subject: [PATCH] fix(api): use reliable path extraction for dual download buttons MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace unreliable findRE regex with split-based path extraction for version detection in API section index pages. The previous regex "[^/]+.*?" was inconsistent and could fail to extract version correctly. Changes: - layouts/_default/api.html: Add dual-button logic for clustered/cloud-dedicated section index pages using split-based URL path extraction - layouts/api/list.html: Replace findRE with split for version extraction - layouts/api/section.html: Add dual-button logic matching api.html The split approach extracts path segments reliably: /influxdb3/clustered/api/ → ["", "influxdb3", "clustered", "api", ""] $version = index 2 = "clustered" --- layouts/_default/api.html | 54 ++++++++++++++++++++++++++++++++++++++- layouts/api/list.html | 13 +++++++--- layouts/api/section.html | 54 ++++++++++++++++++++++++++++++++++++++- 3 files changed, 115 insertions(+), 6 deletions(-) diff --git a/layouts/_default/api.html b/layouts/_default/api.html index 4969a1b1c..39e10cb2c 100644 --- a/layouts/_default/api.html +++ b/layouts/_default/api.html @@ -3,7 +3,17 @@ pages. Delegates to appropriate templates based on page type: - Section pages: Use section.html logic (children listing) - Pages with staticFilePath: Use RapiDoc renderer Note: This template exists as a catch-all but specific templates (api/section.html, api/list.html, api/single.html) should be -preferred. */}} {{/* Section pages without staticFilePath should render content +preferred. */}} + +{{/* Extract product and version from URL path for download buttons */}} +{{/* Example: /influxdb3/clustered/api/ → ["", "influxdb3", "clustered", "api", ""] */}} +{{ $pathParts := split .RelPermalink "/" }} +{{ $version := "" }} +{{ if ge (len $pathParts) 3 }} + {{ $version = index $pathParts 2 }} +{{ end }} + +{{/* Section pages without staticFilePath should render content directly, not use RapiDoc */}} {{ if and .IsSection (not .Params.staticFilePath) }} {{ partial "header.html" . }} {{ partial "topnav.html" . }} @@ -20,6 +30,26 @@ directly, not use RapiDoc */}} {{ if and .IsSection (not .Params.staticFilePath) {{ end }} + {{/* Dual download buttons for Clustered and Cloud Dedicated */}} + {{ if or (eq $version "clustered") (eq $version "cloud-dedicated") }} +
+ + + Download Data API Spec + + + + Download Management API Spec + +
+ {{ end }} + {{/* SECTION INDEX - Show page content then children listing */}} {{ with .Content }}
{{ . }}
@@ -58,3 +88,25 @@ partial "topnav.html" . }} {{ partial "footer.html" . }} {{ end }} + + diff --git a/layouts/api/list.html b/layouts/api/list.html index 5ba786615..f36746f6b 100644 --- a/layouts/api/list.html +++ b/layouts/api/list.html @@ -3,10 +3,15 @@ param) - shows list of tag pages from article data 2. Tag pages (has 'tag' param) - shows RapiDoc with all operations for the tag For conceptual pages (isConceptual: true), shows content without operations. */}} -{{/* Extract product and version from URL for download buttons */}} -{{ $productPathData := findRE "[^/]+.*?" .RelPermalink }} -{{ $product := index $productPathData 0 }} -{{ $version := index $productPathData 1 }} +{{/* Extract product and version from URL path for download buttons */}} +{{/* Example: /influxdb3/clustered/api/ → ["", "influxdb3", "clustered", "api", ""] */}} +{{ $pathParts := split .RelPermalink "/" }} +{{ $product := "" }} +{{ $version := "" }} +{{ if ge (len $pathParts) 3 }} + {{ $product = index $pathParts 1 }} + {{ $version = index $pathParts 2 }} +{{ end }} {{ partial "header.html" . }} {{ partial "topnav.html" . }} diff --git a/layouts/api/section.html b/layouts/api/section.html index d16a59ead..2fbcb70b0 100644 --- a/layouts/api/section.html +++ b/layouts/api/section.html @@ -1,7 +1,17 @@ {{/* API Documentation Section Layout Used for API section index pages (e.g., /influxdb3/core/api/). Shows page content with children listing instead of RapiDoc renderer. For tag pages (with 'tag' param), Hugo uses list.html instead. -*/}} {{ partial "header.html" . }} {{ partial "topnav.html" . }} +*/}} + +{{/* Extract product and version from URL path for download buttons */}} +{{/* Example: /influxdb3/clustered/api/ → ["", "influxdb3", "clustered", "api", ""] */}} +{{ $pathParts := split .RelPermalink "/" }} +{{ $version := "" }} +{{ if ge (len $pathParts) 3 }} + {{ $version = index $pathParts 2 }} +{{ end }} + +{{ partial "header.html" . }} {{ partial "topnav.html" . }}
{{ partial "sidebar.html" . }} @@ -16,6 +26,26 @@ RapiDoc renderer. For tag pages (with 'tag' param), Hugo uses list.html instead. {{ end }} + {{/* Dual download buttons for Clustered and Cloud Dedicated */}} + {{ if or (eq $version "clustered") (eq $version "cloud-dedicated") }} + + {{ end }} + {{/* SECTION INDEX - Show intro content then tag-based children */}} {{ with .Content }}
{{ . }}
@@ -32,3 +62,25 @@ RapiDoc renderer. For tag pages (with 'tag' param), Hugo uses list.html instead.
{{ partial "footer.html" . }} + +