diff options
| author | Serghei Iakovlev <egrep@protonmail.ch> | 2022-07-31 16:52:05 +0200 |
|---|---|---|
| committer | Serghei Iakovlev <egrep@protonmail.ch> | 2022-07-31 16:52:05 +0200 |
| commit | b5eb22732adc53767d9cb7390bb38475276ea880 (patch) | |
| tree | 7f7a9024f1ace3020907c0e5494c3d1eec35a3e5 /assets/js | |
| parent | 70c577c54c04c098f62dcbfff3ef03370ea02df8 (diff) | |
| download | gohugo-theme-ed-b5eb22732adc53767d9cb7390bb38475276ea880.tar.gz | |
Use "guy" falgs to search sentence boundary
Diffstat (limited to 'assets/js')
| -rw-r--r-- | assets/js/search.js | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/assets/js/search.js b/assets/js/search.js index 0f19ca0..c8a8ed8 100644 --- a/assets/js/search.js +++ b/assets/js/search.js @@ -26,8 +26,14 @@ async function initSearchIndex() { this.field('objectID'); this.field('title'); + this.field('lang'); this.field('tags'); + this.field('kind'); + this.field('type'); + this.field('section'); this.field('content'); + this.field('publishDate'); + this.field('lastmod'); this.ref('href'); @@ -167,7 +173,7 @@ function createSearchResultBlurb(query, pageContent) { // term, we need a way to identify where each sentence begins/ends. This // regex will be used to produce a list of all sentences from the page // content. - const sentenceBoundaryRegex = new RegExp(/(?=[^])(?:\P{Sentence_Terminal}|\p{Sentence_Terminal}(?!['"`\p{Close_Punctuation}\p{Final_Punctuation}\s]))*(?:\p{Sentence_Terminal}+['"`\p{Close_Punctuation}\p{Final_Punctuation}]*|$)/, 'gum'); + const sentenceBoundaryRegex = new RegExp(/(?=[^])(?:\P{Sentence_Terminal}|\p{Sentence_Terminal}(?!['"`\p{Close_Punctuation}\p{Final_Punctuation}\s]))*(?:\p{Sentence_Terminal}+['"`\p{Close_Punctuation}\p{Final_Punctuation}]*|$)/, 'guy'); const searchQueryHits = Array.from( pageContent.matchAll(searchQueryRegex), (m) => m.index |
