Skip to content

Commit b8fbea0

Browse files
allows subset in product-availability shortcode - [DOCSENG-40] (#30491)
* allow subset in product-availability shortcode * update styles for spacing and overflow * Update content/en/ddsql_reference/_index.md
1 parent 8803cd5 commit b8fbea0

File tree

2 files changed

+39
-22
lines changed

2 files changed

+39
-22
lines changed

assets/styles/components/_product-availability-labels.scss

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
}
55
strong {
66
white-space: nowrap;
7+
margin-right: 4px;
78
}
89
p {
9-
margin-left: 4px;
1010
.product-wrapper {
1111
white-space: nowrap;
1212
.product {
@@ -18,6 +18,9 @@
1818
top: 1.5px;
1919
}
2020
}
21+
.separator {
22+
margin-right: 4px;
23+
}
2124
}
2225
}
2326
}

layouts/shortcodes/product-availability.html

Lines changed: 35 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,52 @@
11
{{/*
2-
Uses the "products" frontmatter (list)
2+
Displays a list of products related to the current page. Use the "names" parameter to specify and show a subset of products.
33

4-
*FORMAT*
5-
products:
6-
- name: "Product Name 1"
7-
url: "/product-path1"
8-
icon: "product-icon-name1"
9-
- name: "Product Name 2"
10-
url: "/product-path2"
11-
icon: "product-icon-name2"
4+
@param products: array.<{name:string, url:string, icon:string}> - (frontmatter data) list of products.
5+
- name: name of product. should be unique to the array.
6+
- url: path to product documentation
7+
- icon: icon name from our iconfont (websites-modules)
8+
@param names: str - (named parameter) a comma-separated list of product names. Each name must match a product in the products list. Do not include spaces between names.
129

1310
*EXAMPLE*
14-
products:
15-
- name: Cloud SIEM
16-
url: /security/cloud_siem/
17-
icon: siem
18-
- name: Workload Protection
19-
url: /security/threats/
20-
icon: cloud-security-management
11+
products:
12+
- name: Cloud SIEM
13+
url: /security/cloud_siem/
14+
icon: siem
15+
- name: Workload Protection
16+
url: /security/threats/
17+
icon: cloud-security-management
18+
- name: DDSQL Editor
19+
url: /ddsql_editor/
20+
icon: ddsql
21+
22+
{{< product-availability >}} <-- shows all products
23+
OR
24+
{{< product-availability names="Cloud SIEM,DDSQL Editor" >}} <-- only shows 2 of the 3 products
25+
2126
*/}}
2227

28+
{{ $products := .Page.Params.products }}
29+
{{ $names := .Get "names" }}
30+
31+
{{ if $names }}
32+
{{/* if subset of products is requested */}}
33+
{{ $products = where $products "name" "in" (split $names ",") }}
34+
{{ end }}
35+
36+
{{ $len := len $products }}
37+
2338
<div class="product-availability container mb-3 p-0">
2439
<div class="d-flex">
2540
<strong class="p-0">{{ i18n "available_for"}}:</strong>
26-
<p class="mb-0 p-0">
27-
{{ $len := len .Page.Params.products}}
28-
{{ range $idx, $product := .Page.Params.products }}
41+
<p class="mb-0 p-0 d-flex flex-wrap">
42+
{{ range $idx, $product := $products }}
2943
<span class="product-wrapper">
3044
<span class="product position-relative">
3145
{{ partial "icon" (dict "name" $product.icon "size" "14px")}}
3246
<span>{{$product.name}}</span>
33-
<a class="border border-0 stretched-link" href="{{$product.url}}"></a>
47+
<a class="border-0 stretched-link" href="{{$product.url}}"></a>
3448
</span>
35-
<span>{{ if ne $idx (sub $len 1) }}|{{ end }}</span>
49+
<span class="separator">{{ if ne $idx (sub $len 1) }}|{{ end }}</span>
3650
</span>
3751
{{ end }}
3852
</p>

0 commit comments

Comments
 (0)