Skip to content

Commit 5787a9a

Browse files
authored
Merge pull request #3008 from cncf/pagefind
Use PageFind for search
2 parents 163f1cf + a2de621 commit 5787a9a

File tree

21 files changed

+196
-49
lines changed

21 files changed

+196
-49
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ resources/
44
node_modules/
55
.hugo_build.lock
66
.DS_Store
7+
pagefind
78

89
# Local Netlify folder
910
.netlify

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

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,6 @@ git submodule update --init --recursive
5050
npm install
5151
```
5252

53-
You can then run the site using `npm run serve` (select "[Hugo]").
53+
You can then run the site using `npm run serve` (select "[Hugo]"). To have the site run locally with a functioning local search, run `npm run serve:with-pagefind`.
5454

5555
[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://github.com/codespaces/new?repo=cncf/glossary)

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));

assets/scss/_search.scss

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,3 +100,14 @@
100100
}
101101

102102
}
103+
104+
.pagefind-ui__result-link {
105+
color: $link-color !important;
106+
}
107+
.pagefind-ui__search-clear {
108+
padding-left: 20px !important;
109+
padding-right: 20px !important;
110+
}
111+
#search {
112+
margin-top: 40px;
113+
}

config.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ github_repo = "https://github.com/cncf/glossary"
226226
github_branch = "main"
227227

228228
# Google Custom Search Engine ID. Remove or comment out to disable search.
229-
gcs_engine_id = "eda0239a7d3fd0d90"
229+
# gcs_engine_id = "eda0239a7d3fd0d90"
230230

231231
# Enable Algolia DocSearch
232232
algolia_docsearch = false

content/de/search.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
title: Search Results
3+
layout: search
4+
---

content/hi/search.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
title: Search Results
3+
layout: search
4+
---

content/it/search.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
title: Search Results
3+
layout: search
4+
---

content/ja/search.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
title: Search Results
3+
layout: search
4+
---

0 commit comments

Comments
 (0)