Skip to content

Commit a10d773

Browse files
nginx-jackTasoOneAsia
authored andcommitted
ProductSelector: Show selected product
1 parent 1431bfe commit a10d773

File tree

1 file changed

+25
-58
lines changed

1 file changed

+25
-58
lines changed

layouts/partials/sidebar-v2.html

Lines changed: 25 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -6,76 +6,43 @@
66
{{ partial "coveo-atomic-search.html" (dict "id" "search-standalone-sidebar") }}
77
</div>
88

9-
<!-- <div class="header__product-selector">
10-
{{ $nginxProducts := slice
11-
(dict "title" "NGINX One Console" "url" "/nginx-one" "type" "nginx-one")
12-
(dict "title" "NGINX Plus" "url" "/nginx" "type" "nginx-one")
13-
(dict "title" "NGINX Instance Manager" "url" "/nginx-instance-manager" "type" "nginx-one")
14-
(dict "title" "NGINX Ingress Controller" "url" "/nginx-ingress-controller" "type" "nginx-one")
15-
(dict "title" "NGINX Gateway Fabric" "url" "/nginx-gateway-fabric" "type" "nginx-one")
16-
(dict "title" "NGINX Open Source" "url" "https://nginx.org/en/docs/" "type" "nginx-one")
17-
(dict "title" "NGINX Agent" "url" "/nginx-agent" "type" "nginx-one")
18-
(dict "title" "NGINX App Protect WAF" "url" "/nginx-app-protect-waf" "type" "nginx-app-protect")
19-
(dict "title" "NGINX App Protect DoS" "url" "/nginx-app-protect-dos" "type" "nginx-app-protect")
20-
(dict "title" "NGINX as a Service for Azure" "url" "/nginxaas/azure/" "type" "nginx-as-a-service")
21-
(dict "title" "NGINX Unit" "url" "https://unit.nginx.org/" "type" "nginx-other")
22-
}}
23-
{{ $productMap := dict }}
24-
{{ range $nginxProducts }}
25-
{{ if not (or (eq .title "NGINX Open Source" ) (eq .title "NGINX Unit")) }}
26-
{{ $productId := index (split .url "/") 1 }}
27-
{{ $productMap = merge $productMap (dict $productId .title) }}
28-
{{ end }}
9+
{{ $relPermalink := .RelPermalink }}
10+
{{ $productIdentifier := index ((split $relPermalink "/")) 1 }}
11+
{{ $relPermalink := strings.TrimSuffix "/" $productIdentifier }}
12+
{{ $currentProductTitle := "" }}
13+
14+
{{ with index .Site.Data "product-selector" }}
15+
{{ range $group := . }}
16+
{{ range $product := $group.products }}
17+
{{ $splitProductUrl := index ((split $product.url "/")) 1 }}
18+
{{ $suffixProductUrl := strings.TrimSuffix "/" $splitProductUrl | }}
19+
{{ $prefixProductUrl := strings.TrimPrefix "/" $suffixProductUrl | }}
20+
{{ if (eq $prefixProductUrl $productIdentifier) }}
21+
{{ $currentProductTitle = $product.title }}
22+
{{ end }}
2923
{{ end }}
30-
{{ $relPermalink := .RelPermalink }}
31-
{{ $productIdentifier := index ((split $relPermalink "/")) 1 }}
32-
{{ $productName := index $productMap $productIdentifier | default "Product Documentation" }}
24+
{{ end }}
25+
{{ end }}
3326

34-
<button class="product-selector__button" id="product-selector-button">
35-
{{/* product name and selector */}}
36-
<span class="product-name">{{ $productName }}</span>
37-
<span class="product-selector-button-icon">
38-
<svg width="8" height="14" viewBox="0 0 8 14" fill="none" xmlns="http://www.w3.org/2000/svg">
39-
<path d="M1 13L7 7L0.999999 1" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
40-
</svg>
41-
</span>
42-
</button>
43-
<div class="product-selector" id="product-selector" style="display: none">
44-
{{ $groupedProducts := dict
45-
"nginx-one" (where $nginxProducts "type" "nginx-one")
46-
"nginx-app-protect" (where $nginxProducts "type" "nginx-app-protect")
47-
"nginx-as-a-service" (where $nginxProducts "type" "nginx-as-a-service")
48-
"nginx-other" (where $nginxProducts "type" "nginx-other")
49-
}}
50-
{{ $orderedKeys := slice "nginx-one" "nginx-app-protect" "nginx-as-a-service" "nginx-other" }}
51-
{{ range $orderedKeys }}
52-
{{ $type := . }}
53-
{{ $products := index $groupedProducts $type }}
54-
<div class="product-selector-content" id="product-selector-content">
55-
<p>{{ $type | humanize | title | upper }}</p>
56-
<ul>
57-
{{ range $products }}
58-
<li>
59-
<a href="{{ .url }}">{{ .title }}</a>
60-
</li>
61-
{{ end }}
62-
</ul>
63-
</div>
64-
{{ end }}
65-
</div>
66-
</div> -->
6727

6828
<div class="product-selector">
6929
<details class="product-selector__section">
7030
<summary class="product-selector__toggle">
71-
<span class="product-selector__toggle-text">NGINX One</span>
31+
32+
<span class="product-selector__toggle-text">
33+
{{ if $currentProductTitle }}
34+
{{ $currentProductTitle }}
35+
{{ else }}
36+
Product Documentation
37+
{{ end }}
38+
</span>
7239
<span class="product-selector__chevron">
7340
{{ partial "lucide" (dict "context" . "icon" "chevron-right") }}
7441
</span>
7542
</summary>
7643
<div class="product-selector__content">
7744
{{ with index .Site.Data "product-selector" }}
78-
{{ $groups := sort . "order" }}
45+
{{ $groups := . }}
7946
{{ range $group := $groups }}
8047
<h3 class="product-selector__product-group">{{ upper (replace $group.productGroup "-" " ") }}</h3>
8148
<ul>

0 commit comments

Comments
 (0)