File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change 37
37
include_homepage_in_sidebar: true
38
38
extra_css:
39
39
- css/custom.css
40
+ extra_javascript:
41
+ - js/extend-search.js
40
42
markdown_extensions:
41
43
- toc:
42
44
permalink: true
Original file line number Diff line number Diff line change
1
+ const params = new URLSearchParams ( window . location . search ) ;
2
+ const q = params . get ( 'q' ) ;
3
+
4
+ // Ensure single word query is pre- and postfixed with '*' (wildcard char)
5
+ if ( q ) {
6
+ const words = q . split ( / \s + / ) ;
7
+ if ( words . length === 1 ) {
8
+ const word = words [ 0 ] ;
9
+ if ( ! word . startsWith ( '*' ) || ! word . endsWith ( '*' ) ) {
10
+ words [ 0 ] = `*${ word . replace ( / ^ \* / , "" ) . replace ( / \* $ / , "" ) } *` ;
11
+ params . set ( 'q' , words . join ( ' ' ) ) ;
12
+ window . location . href = `${ window . location . pathname } ?${ params . toString ( ) } ` ;
13
+ }
14
+ }
15
+ }
You can’t perform that action at this time.
0 commit comments