Skip to content
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
6 changes: 4 additions & 2 deletions exampleSite/hugo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,7 @@ maxAge = -1
github_repo = "https://github.com/nginxinc/nginx-hugo-theme"
github_subdir = "exampleSite"
enable_last_modified = true
disable_coveo = true
coveo_search_redirect = "/search.html"
coveo_search_redirect = "/search.html"
[params.featureFlags]
disable_coveo = true
disable_qualtrics = true
3 changes: 2 additions & 1 deletion layouts/_default/single.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ <h1>{{ .Title }}</h1>
{{ end }}

{{ partial "version-list" . }}
{{ if .Site.Params.enable_qualtrics }}
{{ $qualtricsEnabled := partial "get-feature-flags.html" "disable_qualtrics" }}
{{ if $qualtricsEnabled }}
{{ partial "qualtrics-feedback.html" }}
{{ end }}
</article>
Expand Down
16 changes: 16 additions & 0 deletions layouts/partials/get-feature-flags.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{{- /* Extract parameter with defaults and validation */ -}}
{{- $featureName := . -}}
{{- $featureFlags := site.Params.featureflags -}}
{{- $featureFlagVal := (index $featureFlags $featureName) | default false -}}

{{- if ne (printf "%T" $featureFlagVal) "bool" -}}
{{ errorf "Expected type of feature flag param %s to be boolean." $featureName }}
{{- end -}}

{{- $param := index $featureFlagVal -}}
{{- $result := false -}}
{{- if not (eq $param true) -}}
{{- $result = true -}}
{{- end -}}

{{- return $result -}}
3 changes: 2 additions & 1 deletion layouts/partials/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
</div>
{{ if ( not ( in .Site.Params.buildtype "package" ) ) }}
<!-- Mobile button -->
{{ if not (or (eq .Site.Params.disable_coveo true) (eq .Site.Params.disable_coveo "true")) }}
{{ $coveoEnabled := partial "get-feature-flags.html" "disable_coveo" }}
{{ if $coveoEnabled }}
<label class="header__search--mobile--search--button"for="search-standalone-header-panel" data-testid="header__search--mobile--search--button">
{{ partial "lucide" (dict "context" . "icon" "search") }}
</label>
Expand Down
12 changes: 7 additions & 5 deletions layouts/partials/meta.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,13 @@
<meta http-equiv="last-modified" content="{{ .Page.Lastmod.Format "02/01/2006" }}" />
{{ end }}


{{ $coveoEnabled := partial "get-feature-flags.html" "disable_coveo" }}
{{ $qualtricsEnabled := partial "get-feature-flags.html" "disable_qualtrics" }}
{{/* set custom CSP to load styles and scripts with special handling for GTM scripts (requires unsafe-inline) and Dev Portal page(s) (requires 'unsafe-eval') */}}
<meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline'
https://consent.trustarc.com/ https://mktg.tags.f5.com/basic/prod/utag.sync.js
{{ if not (or (eq .Site.Params.disable_coveo true) (eq .Site.Params.disable_coveo "true")) }} https://static.cloud.coveo.com/ {{ end }}
https://consent.trustarc.com/
https://mktg.tags.f5.com/basic/prod/utag.sync.js
{{ if $coveoEnabled }}https://static.cloud.coveo.com/{{ end }}
https://*.f5.com/
https://*.netlify.app https://gist.github.com
https://tag.demandbase.com/pscSDsz4.min.js
Expand All @@ -54,8 +56,8 @@
https://cdn.bizible.com/xdc.js
https://f5networksglobalprod.122.2o7.net/
https://f5networksnginxdocs.122.2o7.net/
https://*.siteintercept.qualtrics.com/SIE/?Q_ZID=*
https://siteintercept.qualtrics.com/
{{ if $qualtricsEnabled }}https://*.siteintercept.qualtrics.com/SIE/?Q_ZID=*{{ end }}
{{ if $qualtricsEnabled }}https://siteintercept.qualtrics.com/{{ end }}
{{ if in .Params.doctypes "devportal" }} 'unsafe-eval' {{end}};
worker-src 'self' blob:">
{{/* end */}}
Expand Down
4 changes: 2 additions & 2 deletions layouts/partials/scripts.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
{{ end }}

<!-- Coveo Atomic -->
{{ if not (or (eq .Site.Params.disable_coveo true) (eq .Site.Params.disable_coveo "true")) }}
{{ $coveoEnabled := partial "get-feature-flags.html" "disable_coveo" }}
{{ if $coveoEnabled }}
<script
type="module"
src="https://static.cloud.coveo.com/atomic/v3.19.0/atomic.esm.js"
Expand All @@ -40,7 +41,6 @@
{{ $.Scratch.Set "coveoSc" $coveo}}
{{ $secureCoveo := $.Scratch.Get "coveoSc" | minify | fingerprint "sha512" }}


<script src="{{ $secureCoveo.RelPermalink }}" integrity="{{ $secureCoveo.Data.Integrity }}"type="text/javascript"></script>
{{ end }}

Expand Down
3 changes: 2 additions & 1 deletion layouts/partials/styles.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
<link href="{{ $cssHighlight.RelPermalink }}" rel="stylesheet" type="text/css">

<!-- load CSS Atomic CSS -->
{{ if not (or (eq .Site.Params.disable_coveo true) (eq .Site.Params.disable_coveo "true")) }}
{{ $coveoEnabled := partial "get-feature-flags.html" "disable_coveo" }}
{{ if $coveoEnabled }}
<link
rel="stylesheet"
href="https://static.cloud.coveo.com/atomic/v3.19.0/themes/coveo.css"
Expand Down
3 changes: 2 additions & 1 deletion layouts/search/single.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{{ define "main" }}
{{ if not (or (eq .Site.Params.disable_coveo true) (eq .Site.Params.disable_coveo "true")) }}
{{ $coveoEnabled := partial "get-feature-flags.html" "disable_coveo" }}
{{ if $coveoEnabled }}
<section class="search no-sidebar">
{{ partial "coveo-atomic.html" .}}
</section>
Expand Down
Loading