Skip to content

Commit 932ab2d

Browse files
authored
Added banner to list if front matter is present (#262)
* List: Added banner to list if front matter is present * List: Updated list-main from documentation repo * List: Updated list files + added new banner shortcode * List: Added date checker + moved to partial + added banner to every page * List: Added error to build if md is not provided * List: Change to readFile * List: Moved banner to inside page header * List: Changed to use callout partial in banner partial
1 parent d406661 commit 932ab2d

File tree

5 files changed

+119
-28
lines changed

5 files changed

+119
-28
lines changed

layouts/_default/docs.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
{{ else }}
1616
<main class="content col d-block align-top content-no-toc" role="main">
1717
{{ end }}
18-
18+
1919
<section class="main-layout">
2020
<div class="sidebar-layout" id="sidebar-layout">
2121
<button class="sidebar__mobile__toggle" aria-expanded="false" data-mf="true">{{ partial "lucide" (dict "context" . "icon" "x")}}Close</button>
@@ -33,6 +33,7 @@
3333
{{ end }}
3434
{{ end }}
3535
</section>
36+
{{ partial "banner" .}}
3637
<h1>{{ .Title }}</h1>
3738
{{ $content | safeHTML }}
3839
{{ if eq .Page.Draft true }}{{ partial "draft-badge.html" . }}{{ end }}

layouts/_default/list.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
<h1>{{ .Title }}</h1>
3232
{{ .Content }}
3333

34+
{{ partial "banner" . }}
35+
3436
{{ if (lt .WordCount 1) }}
3537
{{ range .Pages.ByWeight }}
3638
<h2>

layouts/partials/banner.html

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{{- with .Params.banner -}}
2+
{{- if .enabled -}}
3+
<!-- Gather the dates and default to beginning or end of time if frontmatter is not provided -->
4+
{{- $currentDate := now | dateFormat "2006-01-02" -}}
5+
{{- $startDate := index . "start-date" | default "0001-01-01" -}}
6+
{{- $endDate := index . "end-date" | default "9999-12-31" -}}
7+
8+
<!-- Checks that the current date is within bounds-->
9+
{{- if and (ge $currentDate $startDate) (le $currentDate $endDate) -}}
10+
{{- if isset . "md" -}}
11+
<!-- Show markdown if "md" is provided -->
12+
{{- $bannerPage := readFile .md -}}
13+
<div class="banner banner-{{ .type }}">
14+
{{ $bannerPage | markdownify }}
15+
</div>
16+
{{- else -}}
17+
<!-- Show error to writers if "md" is NOT provided -->
18+
{{ errorf "Required front matter parameter 'md' is missing or empty for banner." }}
19+
{{- end -}}
20+
{{- end -}}
21+
{{- end -}}
22+
{{- end -}}

layouts/partials/list-main.html

Lines changed: 84 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,100 @@
11
<div class="list-page">
2-
<div class="col-md-12 col-xl-12 py-md-3 pl-md-5">
2+
{{ $PageTitle := .Title }}
3+
<div class="col-md-12 col-xl-12 py-md-3" style="margin-left: -1.75em;">
34
<div class="page-header list">
45
<h1 class="bd-title">
56
{{ .Title }}
67
</h1>
8+
{{ if .Description }}
9+
<p>
10+
{{ .Description | markdownify }}
11+
</p>
12+
{{ end}}
713
{{ if .Content }}
8-
<p class="bd-lead">
14+
<p>
915
{{ .Content | markdownify }}
1016
</p>
1117
{{ end }}
18+
19+
{{ partial "banner" .}}
1220
</div>
1321
</div>
14-
{{ if lt .WordCount 1 }}
15-
<section class="col-md-12 col-xl-12 py-md-3 pl-md-5" id="section-content-list">
16-
22+
23+
{{ if or (lt .WordCount 1) (eq $PageTitle "F5 NGINX One Console") (eq $PageTitle "F5 NGINX App Protect DoS") (eq $PageTitle "F5 NGINX Plus") }}
24+
<section>
1725
<div class="row">
18-
<div class="card-deck">
19-
{{ range .Pages.ByWeight }}
20-
<div class="col-md-5 card">
21-
<div class="card-body">
22-
<h3 class="card-title">
23-
<i class="fas fa-{{if eq .Kind "page"}}file-alt{{else}}book{{end}} fa-2x card-img-top"></i>
24-
<a href="{{ if .Params.url}}{{ .Params.url}}{{else}}{{ .Permalink }}{{end}}">{{ .Title }}</a>
25-
</h3>
26+
<div class="card-deck">
27+
{{ range .Pages.GroupBy "Section" }}
28+
{{ range .Pages.ByWeight }}
29+
<div class="col-md-5 card">
30+
<div class="card-body">
31+
<h3 class="card-title" style="display: flex; align-items: center; gap: 5px;">
32+
<i class="fas fa-{{if eq .Kind "page"}}file-alt{{else}}book{{end}} fa-lg card-img-top"></i>
33+
<a href="{{ if .Params.url}}{{ .Params.url}}{{else}}{{ .Permalink }}{{end}}">{{ .Title }}</a>
34+
</h3>
35+
{{ if and (eq $PageTitle "F5 NGINX One Console") (eq .Title "How-to guides") }}
36+
<ul style="padding-top: 10px;">
37+
{{ range .Pages }}
38+
{{ if eq .Kind "section" }}
39+
{{ range .Pages }}
40+
<li><a href="{{ .Permalink }}"> {{ .Title }}</a></li>
41+
{{ end }}
42+
{{ end }}
43+
{{ end }}
44+
</ul>
45+
{{ end }}
46+
{{ if and (eq $PageTitle "F5 NGINX One Console") (eq .Title "API")}}
47+
<ul style="padding-top: 10px;">
48+
{{ range .Pages }}
49+
<li><a href="{{ .Permalink }}"> {{ .Title }}</a></li>
50+
{{ end }}
51+
</ul>
52+
{{ end }}
53+
{{ if and (eq $PageTitle "F5 NGINX One Console") (eq .Title "Changelog") }}
54+
{{ partial "changelog-date.html" . }}
55+
{{ end }}
56+
</div>
2657
</div>
27-
</div>
58+
{{ end }}
59+
{{ end }}
60+
</div>
61+
{{ if eq $PageTitle "F5 NGINX One Console" }}
62+
<h1 class="bd-title" style="margin-top: 15px;">Other Products</h1>
63+
{{ $nginxProducts := slice
64+
(dict "title" "NGINX Instance Manager" "url" "/nginx-instance-manager" "imgSrc" "NGINX-Instance-Manager-product-icon" "type" "local-console-option" "description" "Track and control NGINX Open Source and NGINX Plus instances.")
65+
(dict "title" "NGINX Ingress Controller" "url" "/nginx-ingress-controller" "imgSrc" "NGINX-Ingress-Controller-product-icon" "type" "kubernetes-solutions" "description" "Kubernetes traffic management with API gateway, identity, and observability features.")
66+
(dict "title" "NGINX Gateway Fabric" "url" "/nginx-gateway-fabric" "imgSrc" "NGINX-product-icon" "type" "kubernetes-solutions" "description" "Next generation Kubernetes connectivity using the Gateway API.")
67+
(dict "title" "NGINX App Protect WAF" "url" "/nginx-app-protect-waf" "imgSrc" "NGINX-App-Protect-WAF-product-icon" "type" "security" "description" "Lightweight, high-performance, advanced protection against Layer 7 attacks on your apps and APIs.")
68+
(dict "title" "NGINX App Protect DoS" "url" "/nginx-app-protect-dos" "imgSrc" "NGINX-App-Protect-DoS-product-icon" "type" "security" "description" "Defend, adapt, and mitigate against Layer 7 denial-of-service attacks on your apps and APIs.")
69+
(dict "title" "NGINX Plus" "url" "/nginx" "imgSrc" "NGINX-Plus-product-icon-RGB" "type" "modern-app-delivery" "description" "The all-in-one load balancer, reverse proxy, web server, content cache, and API gateway.")
70+
(dict "title" "NGINX Open Source" "url" "https://nginx.org/en/docs/" "imgSrc" "NGINX-product-icon" "type" "modern-app-delivery" "description" "The open source all-in-one load balancer, content cache, and web server")
71+
}}
72+
{{ $groupedProducts := dict
73+
"local-console-option" (where $nginxProducts "type" "local-console-option")
74+
"kubernetes-solutions" (where $nginxProducts "type" "kubernetes-solutions")
75+
"security" (where $nginxProducts "type" "security")
76+
"modern-app-delivery" (where $nginxProducts "type" "modern-app-delivery")
77+
}}
78+
{{ range $type, $products := $groupedProducts }}
79+
<div class="card-deck">
80+
<p style="margin-left: 15px; width: 100%; font-weight: bold;">{{ $type | humanize | title }}</p>
81+
{{ range $products }}
82+
<div class="card" style="margin-top: 0px; {{ if eq (len $products) 1 }}max-width: calc(50% - 30px);{{ else }}min-width: 40%;{{ end }}">
83+
<div class="card-body">
84+
<h3 class="card-title" style="display: flex; align-items: center;">
85+
<img class="card-img-top" src="{{ .Site.BaseURL }}/images/icons/{{ .imgSrc }}.png"/>
86+
<a href="{{ if eq .title "NGINX Open Source" }}{{ .url }}{{ else }}{{ .Site.BaseURL }}{{ .url }}{{ end }}">{{ .title }}</a>
87+
</h3>
88+
<p >
89+
{{ if .description }}{{ .description | markdownify }}{{ end }}
90+
</p>
91+
</div>
92+
</div>
93+
{{ end }}
94+
</div>
2895
{{ end }}
29-
</div>
30-
</div>
96+
{{ end }}
97+
</div>
3198
</section>
32-
{{ end }}
33-
</div>
34-
35-
36-
{{ if not .IsHome }}
37-
<div class="row justify-content-center">
38-
{{ partial "pagination.html" . }}
39-
</div>
40-
{{ end }}
41-
42-
99+
{{end}}
43100
</div>

layouts/shortcodes/banner.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{{- $type := .Get 0 | default (.Get "type") | default "" -}}
2+
{{- $title := .Get 1 | default (.Get "title") | default "" -}}
3+
{{ partial "callout.html" (dict
4+
"class" $type
5+
"title" $title
6+
"icon" "fa-solid fa-triangle-exclamation"
7+
"inline" true
8+
"content" .Inner
9+
) }}

0 commit comments

Comments
 (0)