Skip to content

Commit 68bc21c

Browse files
committed
Swap in PageFind for Google Custom Search
Signed-off-by: Chris Abraham <cjyabraham@gmail.com>
1 parent 680ff1a commit 68bc21c

File tree

15 files changed

+1477
-197
lines changed

15 files changed

+1477
-197
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ website/resources
33
public/
44
go.local.mod
55
go.sum
6-
.DS_Store
6+
.DS_Store
7+
pagefind

website/Dockerfile

Lines changed: 0 additions & 4 deletions
This file was deleted.

website/Makefile

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
serve:
2+
hugo server \
3+
--disableFastRender \
4+
--buildDrafts \
5+
--buildFuture \
6+
--ignoreCache
7+
--printI18nWarnings \
8+
--printMemoryUsage \
9+
--printPathWarnings \
10+
--printUnusedTemplates \
11+
--templateMetrics \
12+
--templateMetricsHints \
13+
--gc
14+
15+
production-build:
16+
git submodule update --init --recursive
17+
hugo \
18+
--minify
19+
npx -y pagefind --site public
20+
21+
preview-build:
22+
git submodule update --init --recursive
23+
hugo \
24+
--baseURL $(DEPLOY_PRIME_URL) \
25+
--buildDrafts \
26+
--buildFuture \
27+
--minify
28+
npx -y pagefind --site public

website/assets/js/search.js

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
Copyright 2018 Google LLC
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
https://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
(function($) {
18+
19+
'use strict';
20+
21+
var Search = {
22+
init: function() {
23+
$(document).ready(function() {
24+
$(document).on('keypress', '.td-search-input', function(e) {
25+
if (e.keyCode !== 13) {
26+
return
27+
}
28+
29+
var query = $(this).val();
30+
var searchPage = $(this).data('search-page') + "?q=" + query;
31+
document.location = searchPage;
32+
33+
return false;
34+
});
35+
36+
});
37+
},
38+
};
39+
40+
Search.init();
41+
42+
43+
}(jQuery));

website/assets/scss/_search.scss

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,15 @@
7676
}
7777
}
7878
}
79+
80+
81+
.pagefind-ui__result-link {
82+
color: $link-color !important;
83+
}
84+
.pagefind-ui__search-clear {
85+
padding-left: 20px !important;
86+
padding-right: 20px !important;
87+
}
88+
#search {
89+
margin-top: 40px;
90+
}

website/config.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ version = "0.0"
9898
url_latest_version = "https://maturitymodel.cncf.io"
9999

100100
# Google Custom Search Engine ID. Remove or comment out to disable search.
101-
gcs_engine_id = "5104307cea6b94e6b"
101+
# gcs_engine_id = "5104307cea6b94e6b"
102102

103103
# Enable Algolia DocSearch
104104
algolia_docsearch = false

website/content/de/contribute/_index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,4 +201,4 @@ cd website
201201
npm installieren
202202
```
203203

204-
Anschließend können Sie die Website mit `hugo server` ausführen.
204+
Anschließend können Sie die Website mit `npm run serve` ausführen.

website/content/en/contribute/_index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,4 +202,4 @@ cd website
202202
npm install
203203
```
204204

205-
You can then run the site using `hugo server`.
205+
Then run the site using `npm run serve`. To have the site run locally with a functioning local search, run `npm run serve:with-pagefind`.

website/docker-compose.yaml

Lines changed: 0 additions & 13 deletions
This file was deleted.

website/layouts/_default/content.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<div class="td-content">
1+
<div data-pagefind-body class="td-content">
22
<h1>{{ .Title }}</h1>
33
{{ with .Params.description }}<div class="lead">{{ . | markdownify }}</div>{{ end }}
44
{{ if (and (not .Params.hide_readingtime) (.Site.Params.ui.readingtime.enable)) }}

0 commit comments

Comments
 (0)