Skip to content

Commit 70d204c

Browse files
committed
Add settings for DocSearch
1 parent 3ef095e commit 70d204c

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

docs/docfx.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,14 @@
3939
"globalMetadata": {
4040
"_appName": "",
4141
"_appTitle": "",
42-
"_enableSearch": true,
42+
"_enableSearch": false,
43+
"_docSearch": {
44+
"enabled": true,
45+
"container": "#docsearch",
46+
"appId": "R2IYF7ETH7",
47+
"apiKey": "599cec31baffa4868cae4e79f180729b", // This appId/apiKey is publicly available for testing. (https://docsearch.algolia.com/docs/DocSearch-v3#testing)
48+
"indexName": "docsearch",
49+
},
4350
"pdf": true
4451
}
4552
}

docs/templates/docsearch/layout/_master.tmpl

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818
<link rel="icon" href="{{_rel}}{{{_appFaviconPath}}}{{^_appFaviconPath}}favicon.ico{{/_appFaviconPath}}">
1919
<link rel="stylesheet" href="{{_rel}}public/docfx.min.css">
2020
<link rel="stylesheet" href="{{_rel}}public/main.css">
21+
{{#_docSearch.enabled}}
22+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@docsearch/css@3" />
23+
<link rel="preconnect" href="https://{{_docSearch.appId}}-dsn.algolia.net" crossorigin />
24+
{{/_docSearch.enabled}}
2125
<meta name="docfx:navrel" content="{{_navRel}}">
2226
<meta name="docfx:tocrel" content="{{_tocRel}}">
2327
{{#_noindex}}<meta name="searchOption" content="noindex">{{/_noindex}}
@@ -77,6 +81,12 @@
7781
<input class="form-control" id="search-query" type="search" disabled placeholder="{{__global.search}}" autocomplete="off" aria-label="Search">
7882
</form>
7983
{{/_enableSearch}}
84+
{{#_docSearch.enabled}}
85+
<form class="search" role="search" id="search">
86+
<div id="docsearch"></div>
87+
</form>
88+
{{/_docSearch.enabled}}
89+
8090
</div>
8191
</div>
8292
</div>
@@ -144,6 +154,18 @@
144154
</div>
145155
</div>
146156
</footer>
157+
158+
{{#_docSearch.enabled}}
159+
<script src="https://cdn.jsdelivr.net/npm/@docsearch/js@3"></script>
160+
<script>
161+
docsearch({
162+
container: "{{_docSearch.container}}",
163+
appId: "{{_docSearch.appId}}",
164+
indexName: "{{_docSearch.indexName}}",
165+
apiKey: "{{_docSearch.apiKey}}",
166+
});
167+
</script>
168+
{{/_docSearch.enabled}}
147169
</body>
148170
{{/redirect_url}}
149171
</html>

0 commit comments

Comments
 (0)