Skip to content

Commit 520e7cc

Browse files
authored
Coveo: Set coveo usage via flag (#424)
1 parent be91073 commit 520e7cc

File tree

6 files changed

+29
-11
lines changed

6 files changed

+29
-11
lines changed

exampleSite/hugo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,5 @@ maxAge = -1
2525
github_repo = "https://github.com/nginxinc/nginx-hugo-theme"
2626
github_subdir = "exampleSite"
2727
enable_last_modified = true
28+
disable_coveo = true
2829
coveo_search_redirect = "/search.html"

layouts/partials/header.html

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@
1212
</div>
1313
{{ if ( not ( in .Site.Params.buildtype "package" ) ) }}
1414
<!-- Mobile button -->
15-
<label class="header__search--mobile--search--button"for="search-standalone-header-panel" data-testid="header__search--mobile--search--button">
16-
{{ partial "lucide" (dict "context" . "icon" "search") }}
17-
</label>
15+
{{ if not (or (eq .Site.Params.disable_coveo true) (eq .Site.Params.disable_coveo "true")) }}
16+
<label class="header__search--mobile--search--button"for="search-standalone-header-panel" data-testid="header__search--mobile--search--button">
17+
{{ partial "lucide" (dict "context" . "icon" "search") }}
18+
</label>
19+
{{ end }}
1820
<div class="header__search" data-testid="header__search">
1921
<!-- Standalone search box. -->
2022
{{ partial "coveo-atomic-search.html" (dict "id" "search-standalone-header") }}

layouts/partials/meta.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@
4040

4141
{{/* 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') */}}
4242
<meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline'
43-
https://consent.trustarc.com/ https://mktg.tags.f5.com/basic/prod/utag.sync.js https://static.cloud.coveo.com/ https://*.f5.com/
43+
https://consent.trustarc.com/ https://mktg.tags.f5.com/basic/prod/utag.sync.js
44+
{{ if not (or (eq .Site.Params.disable_coveo true) (eq .Site.Params.disable_coveo "true")) }} https://static.cloud.coveo.com/ {{ end }}
45+
https://*.f5.com/
4446
https://*.netlify.app https://gist.github.com
4547
https://tag.demandbase.com/pscSDsz4.min.js
4648
https://munchkin.brightfunnel.com/js/build/bf-munchkin.min.js

layouts/partials/scripts.html

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
{{ end }}
1818

1919
<!-- Coveo Atomic -->
20+
{{ if not (or (eq .Site.Params.disable_coveo true) (eq .Site.Params.disable_coveo "true")) }}
2021
<script
2122
type="module"
2223
src="https://static.cloud.coveo.com/atomic/v3.19.0/atomic.esm.js"
@@ -40,10 +41,8 @@
4041
{{ $secureCoveo := $.Scratch.Get "coveoSc" | minify | fingerprint "sha512" }}
4142

4243

43-
<script src="{{ $secureCoveo.RelPermalink }}" integrity="{{ $secureCoveo.Data.Integrity }}"
44-
type="text/javascript"></script>
45-
46-
44+
<script src="{{ $secureCoveo.RelPermalink }}" integrity="{{ $secureCoveo.Data.Integrity }}"type="text/javascript"></script>
45+
{{ end }}
4746

4847
<!-- Load the Redoc resources if we're not using Dev Portal for the API reference layout-->
4948
{{ if not ( eq .Site.Params.useDevPortal true ) }}

layouts/partials/styles.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,12 @@
66

77
{{ $cssHighlight := resources.Get "css/v2/highlight.css" | minify | fingerprint "sha512"}}
88
<link href="{{ $cssHighlight.RelPermalink }}" rel="stylesheet" type="text/css">
9+
910
<!-- load CSS Atomic CSS -->
11+
{{ if not (or (eq .Site.Params.disable_coveo true) (eq .Site.Params.disable_coveo "true")) }}
1012
<link
1113
rel="stylesheet"
1214
href="https://static.cloud.coveo.com/atomic/v3.19.0/themes/coveo.css"
1315
integrity="sha512-m2BufPi8Tc6H2jcQfDj/PIl5H57C9jeqhbDFgFXKTtOhoC4S7ULXmx74FseZ8WXpfdT9uyccMHDBJDrIZlrUUQ=="
1416
crossorigin="anonymous"/>
17+
{{ end }}

layouts/search/single.html

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
{{ define "main" }}
2-
<section class="search no-sidebar">
3-
{{ partial "coveo-atomic.html" .}}
4-
</section>
2+
{{ if not (or (eq .Site.Params.disable_coveo true) (eq .Site.Params.disable_coveo "true")) }}
3+
<section class="search no-sidebar">
4+
{{ partial "coveo-atomic.html" .}}
5+
</section>
6+
{{ else }}
7+
<div class="content" data-testid="content">
8+
<div class="not-found-container" data-testid="not-found-container">
9+
<h1 class="info-header">
10+
Search functionality is unavailable.
11+
</h1>
12+
<a href="{{ .Site.BaseURL | relLangURL }}" aria-label="Return home">Return to the {{ .Site.Title }} homepage.</a>
13+
</div>
14+
</div>
15+
{{ end }}
516
{{ end }}

0 commit comments

Comments
 (0)