Skip to content

Commit af3d53c

Browse files
authored
Merge pull request #46768 from cjyabraham/pagefind2
PageFind for users in China
2 parents 61ffecc + a4191d9 commit af3d53c

File tree

12 files changed

+123
-69
lines changed

12 files changed

+123
-69
lines changed

assets/js/search.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ limitations under the License.
3232
}
3333

3434
var query = $(this).val();
35-
document.location = "{{ "search/" | absURL }}?q=" + query;
35+
var searchPage = $(this).data('search-page') + "?q=" + query;
36+
document.location = searchPage;
3637

3738
return false;
3839
});

assets/scss/_custom.scss

Lines changed: 59 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1324,29 +1324,6 @@ div.alert > em.javascript-required {
13241324
background: #326de6;
13251325
}
13261326

1327-
// Adjust Bing search result page
1328-
#bing-results-container {
1329-
padding: 1em;
1330-
}
1331-
.bing-result {
1332-
margin-bottom: 1em;
1333-
}
1334-
.bing-result-url {
1335-
font-size: 14px;
1336-
}
1337-
.bing-result-snippet {
1338-
color: #666666;
1339-
font-size: 14px;
1340-
}
1341-
#bing-pagination-container {
1342-
padding: 1em;
1343-
margin-bottom: 1em;
1344-
1345-
a.bing-page-anchor {
1346-
padding: 0.5em;
1347-
margin: 0.25em;
1348-
}
1349-
}
13501327

13511328
// Adjust Search-bar search-icon
13521329
.search-bar {
@@ -1378,6 +1355,65 @@ div.alert > em.javascript-required {
13781355
padding: .5em 0 .5em 0;
13791356
}
13801357

1358+
// PageFind Styles
1359+
1360+
#search .pagefind-ui form input {
1361+
background-color: #fff;
1362+
border: 1px solid #4c4c4c;
1363+
border-radius: 20px;
1364+
overflow-x: hidden;
1365+
width: auto;
1366+
padding: 6px 10px !important;
1367+
margin: 20px 10px 20px 0;
1368+
1369+
&:focus-within {
1370+
outline: 1.5px solid rgba(47, 135, 223, 0.7);
1371+
border: 1px solid rgba(47, 135, 223, 0.7);
1372+
}
1373+
}
1374+
1375+
#search .pagefind-ui ol.pagefind-ui__results {
1376+
padding-left: 0;
1377+
}
1378+
1379+
#search .pagefind-ui .pagefind-ui__result-nested {
1380+
padding-left: 2em;
1381+
}
1382+
1383+
#search .pagefind-ui.pagefind-ui__result-nested::before {
1384+
content: "\2937 ";
1385+
color: $blue;
1386+
}
1387+
1388+
#search .pagefind-ui ol > li {
1389+
list-style-type: none;
1390+
border-top: 1.5px solid rgba(47, 135, 223, 0.7);
1391+
padding: 10px;
1392+
}
1393+
1394+
#search .pagefind-ui button {
1395+
color: #fff;
1396+
background-color: $blue;
1397+
border-radius: 0.2em;
1398+
border: 0.1rem solid $medium-grey;
1399+
padding: 0.3em;
1400+
}
1401+
1402+
#search .pagefind-ui__result-tags {
1403+
font-size: 14px;
1404+
font-weight: 400;
1405+
}
1406+
1407+
#search a.pagefind-ui__result-link {
1408+
font-weight: 700;
1409+
font-size: 1.15rem;
1410+
}
1411+
1412+
body.td-search #search {
1413+
margin-top: 1rem;
1414+
margin-bottom: 3rem;
1415+
}
1416+
13811417
/* CSS for 'figure' full-screen display */
13821418

13831419
/* Define styles for full-screen overlay */

layouts/_default/baseof.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ <h1>{{ block "hero-title" . }}{{ .Params.bigheader | default .Title }}{{ end }}<
3232
{{ end }}
3333
{{ end }}
3434
<div class="td-outer">
35-
<main role="main" class="td-main">
35+
<main role="main" class="td-main" {{ if (or (ne .FirstSection "case-studies") (not .IsSection) ) }}data-pagefind-body{{ end }}>
3636
{{ block "main" . }}{{ end }}
3737
</main>
3838
</div>

layouts/_default/search.html

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
</form>
2525
</div>
2626
<div class="col-12 col-md-8 offset-md-2">
27-
<h2 class="search-title ml-3">{{ .Title }}</h2>
2827
{{ if .Site.Params.gcs_engine_id }}
2928
<script>
3029
(function() {
@@ -40,9 +39,9 @@ <h2 class="search-title ml-3">{{ .Title }}</h2>
4039
<gcse:searchresults-only></gcse:searchresults-only>
4140
{{ else if .Site.Params.k8s_search }}
4241
<script src="{{ "js/search.js" | relURL }}"></script>
42+
<script src="/pagefind/pagefind-ui.js"></script>
4343
<gcse:searchresults-only linktarget="_parent">
44-
<div id="bing-results-container">{{ T "layouts_docs_search_fetching" }}</div>
45-
<div id="bing-pagination-container"></div>
44+
<div id="search" style="display:none"></div>
4645
</gcse:searchresults-only>
4746
{{ end }}
4847
</div>

layouts/blog/baseof.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@
2929
<div class="col-12 col-md-3 col-xl-2 td-sidebar d-print-none">
3030
{{ partial "blog-sidebar.html" . }}
3131
</div>
32-
<main class="col-12 col-md-9 col-xl-8 pl-md-5 pr-md-4" role="main">
32+
<main class="col-12 col-md-9 col-xl-8 pl-md-5 pr-md-4" role="main"
33+
{{ if .IsPage }}data-pagefind-body data-pagefind-meta="date:{{ $.Date.Format "2006-01-02" }}"{{ end }}
34+
><!-- inside main element -->
3335
{{ block "deprecated" . }}
3436
{{ partial "deprecation-warning.html" . }}
3537
{{ end }}

layouts/case-studies/single-baseof.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
<body>
77
{{ partial "navbar.html" . }}
88
{{ partial "deprecation-warning.html" . }}
9+
<div data-pagefind-body>
910
{{ block "main" . }}{{ end }}
11+
</div>
1012
{{ partialCached "footer.html" . }}
1113
{{ partialCached "scripts.html" . }}
1214

layouts/docs/baseof.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
</div>
2323
<div id="maindoc" class="split pl-md-5 row">
2424
<!--main class="col-12 col-md-9 col-xl-8 pl-md-5" role="main"-->
25-
<main role="main" class="col-xl-8">
25+
<main role="main" class="col-xl-8" {{ if ne .Params.cid "docsHome" }}data-pagefind-body{{ end }}{{ if (and .IsPage .Params.description ) }} data-pagefind-meta="description:{{ .Params.description }}"{{ end }}>
2626
{{ if not .Site.Params.ui.breadcrumb_disable }}{{ partial "breadcrumb.html" . }}{{ end }}
2727
{{ block "deprecated" . }}
2828
{{ partial "deprecation-warning.html" . }}

layouts/docs/glossary.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ <h1>{{ .Title }}</h1>
4141
<li class="{{ $.Scratch.Get "tag_classes" }} hide" data-show-count="0">
4242
<div id="{{ $term_identifier }}" class="term-anchor"></div>
4343
<div>
44-
<div class="term-name"><b>{{ .Title }}</b><a href="{{ printf "#%s" $term_identifier }}" class="permalink hide">LINK</a></div>
44+
<div class="term-name" term="{{ .Title}}" data-pagefind-index-attrs="term"><b>{{ .Title }}</b><a href="{{ printf "#%s" $term_identifier }}" class="permalink hide">LINK</a></div>
4545
{{ with .Params.aka }}
4646
{{ T "layouts_docs_glossary_aka" }}: <i>{{ delimit . ", " }}</i>
4747
<br>

layouts/partials/docs/content-page.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{{ if not .page.Params.notitle }}
2-
<h1>{{ .page.Title }}</h1>
2+
<h1 data-pagefind-weight="10">{{ .page.Title }}</h1>
33
{{ $desc := .page.Description }}
44
{{ with .page.Params.description }}<div class="lead">{{ $desc | markdownify }}</div>{{ end }}
55
{{ end }}

layouts/partials/search-input.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,20 @@
2222
>
2323
</div>
2424
{{ else if .Site.Params.k8s_search }}
25+
26+
{{ $lang := .Site.Language.Lang }}
27+
{{ $searchFile := printf "content/%s/search.md" $lang }}
28+
2529
<div class="search-bar">
2630
<i class="search-icon fas fa-search"></i>
2731
<input
2832
type="search"
2933
name="q"
34+
{{ if fileExists $searchFile }}
35+
data-search-page="{{ "search/" | relLangURL }}"
36+
{{ else }}
37+
data-search-page="{{ "search/" | relURL }}"
38+
{{ end }}
3039
class="search-input td-search-input"
3140
placeholder="{{ T "ui_search_placeholder" }}"
3241
aria-label="{{ T "ui_search_placeholder" }}"

0 commit comments

Comments
 (0)