Skip to content

Commit d9d61f4

Browse files
authored
Add Lunr as a site search option (github#17388)
* Add Lunr as a site search option * Use a class like the Algolia option does * Lint * Working on showing real content, prep for highlighting * Move searching to their own files * Split out ridiculous fn * Add highlighting * Less lunr search code * A little more tidy * Then chain on write too * Mark from server too * Write a batch of indices * Update compress.js * Highlighting with fewer calls * Update lunr-search.js * Update lunr-search.js * Update lunr-search.js * Update lunr-search.js * Update lunr-search.js * Update lunr-search.js
1 parent bd0b0d0 commit d9d61f4

53 files changed

Lines changed: 237 additions & 8 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

javascripts/search.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ function tmplSearchResult ({ url, breadcrumbs, heading, title, content }) {
287287
)
288288
}
289289

290-
// Convert em to mark tags in search responses
290+
// Convert mark tags in search responses
291291
function markify (text) {
292292
const { mark } = tags
293293
return text

lib/search/compress.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
const { promisify } = require('util')
2+
const zlib = require('zlib')
3+
const brotliCompress = promisify(zlib.brotliCompress)
4+
const brotliDecompress = promisify(zlib.brotliDecompress)
5+
6+
const options = {
7+
params: {
8+
[zlib.constants.BROTLI_PARAM_MODE]: zlib.constants.BROTLI_MODE_TEXT,
9+
[zlib.constants.BROTLI_PARAM_QUALITY]: 6
10+
}
11+
}
12+
13+
module.exports = {
14+
async compress (data) {
15+
return brotliCompress(data, options)
16+
},
17+
18+
async decompress (data) {
19+
return brotliDecompress(data, options)
20+
}
21+
}
487 KB
Binary file not shown.
1.1 MB
Binary file not shown.
565 KB
Binary file not shown.
2.63 MB
Binary file not shown.
527 KB
Binary file not shown.
3.42 MB
Binary file not shown.
494 KB
Binary file not shown.
1.11 MB
Binary file not shown.

0 commit comments

Comments
 (0)