Skip to content

Added banner to list if front matter is present #262

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
May 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion layouts/_default/docs.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
{{ else }}
<main class="content col d-block align-top content-no-toc" role="main">
{{ end }}

<section class="main-layout">
<div class="sidebar-layout" id="sidebar-layout">
<button class="sidebar__mobile__toggle" aria-expanded="false" data-mf="true">{{ partial "lucide" (dict "context" . "icon" "x")}}Close</button>
Expand All @@ -84,6 +84,7 @@
{{ end }}
{{ end }}
</section>
{{ partial "banner" .}}
<h1>{{ .Title }}</h1>
{{ $content | safeHTML }}
{{ if eq .Page.Draft true }}{{ partial "draft-badge.html" . }}{{ end }}
Expand Down
2 changes: 2 additions & 0 deletions layouts/_default/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
<h1>{{ .Title }}</h1>
{{ .Content }}

{{ partial "banner" . }}

{{ if (lt .WordCount 1) }}
{{ range .Pages.ByWeight }}
<h2>
Expand Down
22 changes: 22 additions & 0 deletions layouts/partials/banner.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{{- with .Params.banner -}}
{{- if .enabled -}}
<!-- Gather the dates and default to beginning or end of time if frontmatter is not provided -->
{{- $currentDate := now | dateFormat "2006-01-02" -}}
{{- $startDate := index . "start-date" | default "0001-01-01" -}}
{{- $endDate := index . "end-date" | default "9999-12-31" -}}

<!-- Checks that the current date is within bounds-->
{{- if and (ge $currentDate $startDate) (le $currentDate $endDate) -}}
{{- if isset . "md" -}}
<!-- Show markdown if "md" is provided -->
{{- $bannerPage := readFile .md -}}
<div class="banner banner-{{ .type }}">
{{ $bannerPage | markdownify }}
</div>
{{- else -}}
<!-- Show error to writers if "md" is NOT provided -->
{{ errorf "Required front matter parameter 'md' is missing or empty for banner." }}
{{- end -}}
{{- end -}}
{{- end -}}
{{- end -}}
111 changes: 84 additions & 27 deletions layouts/partials/list-main.html
Original file line number Diff line number Diff line change
@@ -1,43 +1,100 @@
<div class="list-page">
<div class="col-md-12 col-xl-12 py-md-3 pl-md-5">
{{ $PageTitle := .Title }}
<div class="col-md-12 col-xl-12 py-md-3" style="margin-left: -1.75em;">
<div class="page-header list">
<h1 class="bd-title">
{{ .Title }}
</h1>
{{ if .Description }}
<p>
{{ .Description | markdownify }}
</p>
{{ end}}
{{ if .Content }}
<p class="bd-lead">
<p>
{{ .Content | markdownify }}
</p>
{{ end }}

{{ partial "banner" .}}
</div>
</div>
{{ if lt .WordCount 1 }}
<section class="col-md-12 col-xl-12 py-md-3 pl-md-5" id="section-content-list">

{{ if or (lt .WordCount 1) (eq $PageTitle "F5 NGINX One Console") (eq $PageTitle "F5 NGINX App Protect DoS") (eq $PageTitle "F5 NGINX Plus") }}
<section>
<div class="row">
<div class="card-deck">
{{ range .Pages.ByWeight }}
<div class="col-md-5 card">
<div class="card-body">
<h3 class="card-title">
<i class="fas fa-{{if eq .Kind "page"}}file-alt{{else}}book{{end}} fa-2x card-img-top"></i>
<a href="{{ if .Params.url}}{{ .Params.url}}{{else}}{{ .Permalink }}{{end}}">{{ .Title }}</a>
</h3>
<div class="card-deck">
{{ range .Pages.GroupBy "Section" }}
{{ range .Pages.ByWeight }}
<div class="col-md-5 card">
<div class="card-body">
<h3 class="card-title" style="display: flex; align-items: center; gap: 5px;">
<i class="fas fa-{{if eq .Kind "page"}}file-alt{{else}}book{{end}} fa-lg card-img-top"></i>
<a href="{{ if .Params.url}}{{ .Params.url}}{{else}}{{ .Permalink }}{{end}}">{{ .Title }}</a>
</h3>
{{ if and (eq $PageTitle "F5 NGINX One Console") (eq .Title "How-to guides") }}
<ul style="padding-top: 10px;">
{{ range .Pages }}
{{ if eq .Kind "section" }}
{{ range .Pages }}
<li><a href="{{ .Permalink }}"> {{ .Title }}</a></li>
{{ end }}
{{ end }}
{{ end }}
</ul>
{{ end }}
{{ if and (eq $PageTitle "F5 NGINX One Console") (eq .Title "API")}}
<ul style="padding-top: 10px;">
{{ range .Pages }}
<li><a href="{{ .Permalink }}"> {{ .Title }}</a></li>
{{ end }}
</ul>
{{ end }}
{{ if and (eq $PageTitle "F5 NGINX One Console") (eq .Title "Changelog") }}
{{ partial "changelog-date.html" . }}
{{ end }}
</div>
</div>
</div>
{{ end }}
{{ end }}
</div>
{{ if eq $PageTitle "F5 NGINX One Console" }}
<h1 class="bd-title" style="margin-top: 15px;">Other Products</h1>
{{ $nginxProducts := slice
(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.")
(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.")
(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.")
(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.")
(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.")
(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.")
(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")
}}
{{ $groupedProducts := dict
"local-console-option" (where $nginxProducts "type" "local-console-option")
"kubernetes-solutions" (where $nginxProducts "type" "kubernetes-solutions")
"security" (where $nginxProducts "type" "security")
"modern-app-delivery" (where $nginxProducts "type" "modern-app-delivery")
}}
{{ range $type, $products := $groupedProducts }}
<div class="card-deck">
<p style="margin-left: 15px; width: 100%; font-weight: bold;">{{ $type | humanize | title }}</p>
{{ range $products }}
<div class="card" style="margin-top: 0px; {{ if eq (len $products) 1 }}max-width: calc(50% - 30px);{{ else }}min-width: 40%;{{ end }}">
<div class="card-body">
<h3 class="card-title" style="display: flex; align-items: center;">
<img class="card-img-top" src="{{ .Site.BaseURL }}/images/icons/{{ .imgSrc }}.png"/>
<a href="{{ if eq .title "NGINX Open Source" }}{{ .url }}{{ else }}{{ .Site.BaseURL }}{{ .url }}{{ end }}">{{ .title }}</a>
</h3>
<p >
{{ if .description }}{{ .description | markdownify }}{{ end }}
</p>
</div>
</div>
{{ end }}
</div>
{{ end }}
</div>
</div>
{{ end }}
</div>
</section>
{{ end }}
</div>


{{ if not .IsHome }}
<div class="row justify-content-center">
{{ partial "pagination.html" . }}
</div>
{{ end }}


{{end}}
</div>
9 changes: 9 additions & 0 deletions layouts/shortcodes/banner.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{{- $type := .Get 0 | default (.Get "type") | default "" -}}
{{- $title := .Get 1 | default (.Get "title") | default "" -}}
{{ partial "callout.html" (dict
"class" $type
"title" $title
"icon" "fa-solid fa-triangle-exclamation"
"inline" true
"content" .Inner
) }}
Loading