Skip to content

Commit 21ece19

Browse files
committed
fix(ci): add path offset to product-name and sidebar for PR previews
Apply the same prPreviewPathOffset fix to product-name.html and sidebar.html that was applied in the initial PR #6665. These templates parse RelPermalink to detect product context, but when baseURL includes a subdirectory path (e.g., /docs-v2/pr-preview/pr-XXXX/), the path indices shift. This fix uses the configurable offset to skip extra path segments in PR preview builds.
1 parent 78c7a98 commit 21ece19

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

layouts/partials/sidebar.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
{{ $currentPage := . }}
22
{{ $productPathData := findRE "[^/]+.*?" .RelPermalink }}
3-
{{ $product := index $productPathData 0 }}
3+
{{/* Support deployments (such as CI tools) with subdirectory baseURL */}}
4+
{{ $pathOffset := .Site.Params.prPreviewPathOffset | default 0 }}
5+
{{ $product := index $productPathData (add $pathOffset 0) }}
46
{{ $productName := (index .Site.Data.products $product).name }}
5-
{{ $currentVersion := index $productPathData 1 }}
7+
{{ $currentVersion := index $productPathData (add $pathOffset 1) }}
68

79
<!-- Menu Key -->
810
{{ .Scratch.Set "menuKey" "menu"}}

layouts/shortcodes/product-name.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
{{- $productPathData := findRE "[^/]+.*?" .Page.RelPermalink -}}
2-
{{- $currentProduct := index $productPathData 1 -}}
2+
{{- /* Support deployments (such as CI tools) with subdirectory baseURL */ -}}
3+
{{- $pathOffset := .Site.Params.prPreviewPathOffset | default 0 -}}
4+
{{- $currentProduct := index $productPathData (add $pathOffset 1) -}}
35
{{- $length := .Get 0 | default "long" -}}
46
{{- $omit := .Get "omit" | default "" -}}
57
{{- $scratch := newScratch -}}

0 commit comments

Comments
 (0)