Skip to content

Commit 8754188

Browse files
committed
Updated site search documentation
1 parent 257a737 commit 8754188

File tree

2 files changed

+54
-49
lines changed

2 files changed

+54
-49
lines changed

docs/insiders.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ tied to it are merged back into Material for MkDocs and released for general
3232
availability. Bugfixes will always be released simultaneously in both editions.
3333

3434
See the [roadmap][4] for a list of already available and upcoming features, and
35-
for demonstration purposes, [the official docs][5] built with Material for
36-
MkDocs Insiders.
35+
for demonstration purposes, [the official documentation][5] built with Material
36+
for MkDocs Insiders.
3737

3838
[4]: #roadmap
3939
[5]: https://squidfunk.github.io/mkdocs-material-insiders/
@@ -75,7 +75,7 @@ in Material for MkDocs Insiders.
7575
### Madame Jeanette
7676

7777
[:octicons-fire-24: Funding goal: __$500__][6] ·
78-
:octicons-lock-24: Status: _exclusively available_
78+
:octicons-lock-24: Status: _exclusive_
7979

8080
New features and improvements for _search_, including:
8181

@@ -88,11 +88,11 @@ New features and improvements for _search_, including:
8888
### Prairie Fire
8989

9090
[:octicons-fire-24: Funding goal: __$1,000__][6] ·
91-
:octicons-lock-24: Status: _pending_
91+
:octicons-lock-24: Status: _exclusive_
9292

9393
New features and improvements for _content and toc_, including:
9494

95-
- [ ] Highlighting of matched search terms in content area
95+
- [x] Highlighting of matched search terms in content area
9696
- [ ] Better support for wide screens, i.e. more horizontal space
9797
- [ ] Table of contents can be moved into navigation for more space
9898
- [ ] Table of contents shows which sections have search results

docs/setup/setting-up-site-search.md

Lines changed: 49 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ made available [offline][1].
1717

1818
[:octicons-file-code-24: Source][2] ·
1919
[:octicons-cpu-24: Plugin][3] ·
20-
[:octicons-heart-fill-24:{: .tx-heart } Insiders: new search UI/UX](../insiders.md){: .tx-insiders }
20+
[:octicons-heart-fill-24:{: .tx-heart } Insiders – improved user experience][4]{: .tx-insiders }
2121

2222
The [built-in search plugin][3] integrates seamlessly with Material for MkDocs,
23-
adding multilingual client-side search with [lunr][4] and [lunr-languages][5].
23+
adding multilingual client-side search with [lunr][5] and [lunr-languages][6].
2424
It's enabled by default, but must be re-added to `mkdocs.yml` when other plugins
2525
are used:
2626

@@ -34,9 +34,9 @@ The following options are supported:
3434
`lang`{: #lang }
3535

3636
: :octicons-milestone-24: Default: _automatically set_ – This option allows
37-
to include the language-specific stemmers provided by [lunr-languages][5].
37+
to include the language-specific stemmers provided by [lunr-languages][6].
3838
Note that Material for MkDocs will set this automatically based on the
39-
[site language][6], but it may be overridden, e.g. to support multiple
39+
[site language][7], but it may be overridden, e.g. to support multiple
4040
languages:
4141

4242
=== "A single language"
@@ -106,7 +106,7 @@ The following options are supported:
106106
`prebuild_index`{: #prebuild-index }
107107

108108
: :octicons-milestone-24: Default: `false` · :octicons-beaker-24:
109-
Experimental – MkDocs can generate a [prebuilt index][7] of all pages during
109+
Experimental – MkDocs can generate a [prebuilt index][8] of all pages during
110110
build time, which provides performance improvements at the cost of more
111111
bandwidth, as it reduces the build time of the search index:
112112

@@ -126,50 +126,55 @@ them at your own risk._
126126

127127
[2]: https://github.com/squidfunk/mkdocs-material/tree/master/src/assets/javascripts/integrations/search
128128
[3]: https://www.mkdocs.org/user-guide/configuration/#search
129-
[4]: https://lunrjs.com
130-
[5]: https://github.com/MihaiValentin/lunr-languages
131-
[6]: changing-the-language.md#site-language
132-
[7]: https://www.mkdocs.org/user-guide/configuration/#prebuild_index
129+
[4]: ../insiders.md
130+
[5]: https://lunrjs.com
131+
[6]: https://github.com/MihaiValentin/lunr-languages
132+
[7]: changing-the-language.md#site-language
133+
[8]: https://www.mkdocs.org/user-guide/configuration/#prebuild_index
133134

134135
### Highlighting search
135136

136-
[:octicons-file-code-24: Source][2] ·
137+
[:octicons-file-code-24: Source][4] ·
137138
:octicons-unlock-24: Feature flag ·
138139
:octicons-beaker-24: Experimental ·
139-
[:octicons-heart-fill-24:{: .tx-heart } Insiders](../insiders.md){: .tx-insiders }
140+
[:octicons-heart-fill-24:{: .tx-heart } Insiders only][4]{: .tx-insiders }
140141

141-
When `search.highlighting` is activated and a user clicks on a search result,
142-
Material for MkDocs will highlight all occurrences. It can be enabled via
143-
`mkdocs.yml` with:
142+
When _search highlighting_ is activated and a user clicks on a search result,
143+
Material for MkDocs will highlight all occurrences after following the link.
144+
It can be enabled via `mkdocs.yml` with:
144145

145146
``` yaml
146147
theme:
147148
features:
148149
- search.highlight
149150
```
150151

151-
When searching for `"code blocks"`, the resulting page will look like:
152+
Searching for `"code blocks"` yields:
153+
154+
[![Search highlighting][9]][9]
152155

153-
![Search highlighting][8]
156+
_Give this feature a try on [the official documentation][10] built with Material
157+
for MkDocs Insiders!_
154158

155-
[8]: ../assets/search-highlighting.png
159+
[9]: ../assets/search-highlighting.png
160+
[10]: https://squidfunk.github.io/mkdocs-material-insiders/reference/code-blocks/?h=code+blocks
156161

157162
### Offline search
158163

159-
[:octicons-file-code-24: Source][9] ·
160-
[:octicons-cpu-24: Plugin][10] · :octicons-beaker-24: Experimental
164+
[:octicons-file-code-24: Source][11] ·
165+
[:octicons-cpu-24: Plugin][12] · :octicons-beaker-24: Experimental
161166

162167
If you distribute your documentation as `*.html` files, the built-in search
163168
will not work out-of-the-box due to the restrictions modern browsers impose for
164-
security reasons. This can be mitigated with the [localsearch][10] plugin in
165-
combination with @squidfunk's [iframe-worker][11] polyfill.
169+
security reasons. This can be mitigated with the [localsearch][12] plugin in
170+
combination with @squidfunk's [iframe-worker][13] polyfill.
166171

167-
For setup instructions, refer to the [official documentation][12].
172+
For setup instructions, refer to the [official documentation][14].
168173

169-
[9]: https://github.com/squidfunk/mkdocs-material/blob/master/src/base.html#L378-L390
170-
[10]: https://github.com/wilhelmer/mkdocs-localsearch/
171-
[11]: https://github.com/squidfunk/iframe-worker
172-
[12]: https://github.com/wilhelmer/mkdocs-localsearch#installation-material-v5
174+
[11]: https://github.com/squidfunk/mkdocs-material/blob/master/src/base.html#L378-L390
175+
[12]: https://github.com/wilhelmer/mkdocs-localsearch/
176+
[13]: https://github.com/squidfunk/iframe-worker
177+
[14]: https://github.com/wilhelmer/mkdocs-localsearch#installation-material-v5
173178

174179
## Customization
175180

@@ -183,12 +188,12 @@ your needs.
183188

184189
### Query transformation
185190

186-
[:octicons-file-code-24: Source][13] ·
191+
[:octicons-file-code-24: Source][15] ·
187192
:octicons-mortar-board-24: Difficulty: _easy_
188193

189194
When a user enters a query into the search box, the query is pre-processed
190195
before it is submitted to the search index. Material for MkDocs will apply the
191-
following transformations, which can be customized by [extending the theme][14]:
196+
following transformations, which can be customized by [extending the theme][16]:
192197

193198
``` ts
194199
/**
@@ -213,12 +218,12 @@ following transformations, which can be customized by [extending the theme][14]:
213218
* asterisk (wildcard) in between terms, which can be denoted by whitespace,
214219
* any non-control character, or a word boundary.
215220
*
216-
* @param value - Query value
221+
* @param query - Query value
217222
*
218223
* @return Transformed query value
219224
*/
220-
function defaultTransform(value: string): string {
221-
return value
225+
function defaultTransform(query: string): string {
226+
return query
222227
.split(/"([^"]+)"/g) /* => 1 */
223228
.map((terms, i) => i & 1
224229
? terms.replace(/^\b|^(?![^\x00-\x7F]|$)|\s+/g, " +")
@@ -234,7 +239,7 @@ function defaultTransform(value: string): string {
234239
If you want to switch to the default behavior of the `mkdocs` or `readthedocs`
235240
template, both of which don't transform the query prior to submission, or
236241
customize the `transform` function, you can do this by [overriding the
237-
`config` block][15]:
242+
`config` block][17]:
238243

239244
``` html
240245
{% block config %}
@@ -251,19 +256,19 @@ customize the `transform` function, you can do this by [overriding the
251256
The `transform` function will receive the query string as entered by the user
252257
and must return the processed query string to be submitted to the search index.
253258

254-
[13]: https://github.com/squidfunk/mkdocs-material/blob/master/src/assets/javascripts/integrations/search/transform/index.ts
255-
[14]: ../customization.md#extending-the-theme
256-
[15]: ../customization.md#overriding-blocks
259+
[15]: https://github.com/squidfunk/mkdocs-material/blob/master/src/assets/javascripts/integrations/search/transform/index.ts
260+
[16]: ../customization.md#extending-the-theme
261+
[17]: ../customization.md#overriding-blocks
257262

258263
### Custom search
259264

260-
[:octicons-file-code-24: Source][16] ·
265+
[:octicons-file-code-24: Source][18] ·
261266
:octicons-mortar-board-24: Difficulty: _challenging_
262267

263-
Material for MkDocs implements search as part of a [web worker][17]. If you
268+
Material for MkDocs implements search as part of a [web worker][19]. If you
264269
want to switch the web worker with your own implementation, e.g. to submit
265270
search to an external service, you can add a custom JavaScript file to the `docs`
266-
directory and [override the `config` block][15]:
271+
directory and [override the `config` block][17]:
267272

268273
``` html
269274
{% block config %}
@@ -280,8 +285,8 @@ message format using _discriminated unions_, i.e. through the `type` property
280285
of the message. See the following interface definitions to learn about the
281286
message formats:
282287

283-
* [:octicons-file-code-24: `SearchMessage`][18]
284-
* [:octicons-file-code-24: `SearchIndex` and `SearchResult`][19]
288+
* [:octicons-file-code-24: `SearchMessage`][20]
289+
* [:octicons-file-code-24: `SearchIndex` and `SearchResult`][21]
285290

286291
The sequence and direction of messages is rather intuitive:
287292

@@ -290,7 +295,7 @@ The sequence and direction of messages is rather intuitive:
290295
* :octicons-arrow-right-24: `SearchQueryMessage`
291296
* :octicons-arrow-left-24: `SearchResultMessage`
292297

293-
[16]: https://github.com/squidfunk/mkdocs-material/blob/master/src/assets/javascripts/integrations/search/worker
294-
[17]: https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers
295-
[18]: https://github.com/squidfunk/mkdocs-material/blob/master/src/assets/javascripts/integrations/search/worker/message/index.ts
296-
[19]: https://github.com/squidfunk/mkdocs-material/blob/master/src/assets/javascripts/integrations/search/_/index.ts
298+
[18]: https://github.com/squidfunk/mkdocs-material/blob/master/src/assets/javascripts/integrations/search/worker
299+
[19]: https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers
300+
[20]: https://github.com/squidfunk/mkdocs-material/blob/master/src/assets/javascripts/integrations/search/worker/message/index.ts
301+
[21]: https://github.com/squidfunk/mkdocs-material/blob/master/src/assets/javascripts/integrations/search/_/index.ts

0 commit comments

Comments
 (0)