@@ -5,11 +5,11 @@ var cheerio = require("cheerio");
5
5
6
6
7
7
// Change these constants to suit your needs
8
- const HTML_FOLDER = "../../" ; // folder with your HTML files
8
+ const HTML_FOLDER = "../../__site " ; // folder with your HTML files
9
9
// Valid search fields: "title", "description", "keywords", "body"
10
10
const SEARCH_FIELDS = [ "description" , "keywords" , "body" ] ;
11
11
const EXCLUDE_FILES = [ "search.html" , "404.html" ] ;
12
- const EXCLUDE_FOLDERS = [ "node_modules" , "css" , "assets " , "libs " , "search" , "tag" ] ;
12
+ const EXCLUDE_FOLDERS = [ "node_modules" , "css" , "libs " , "assets " , "search" , "tag" ] ;
13
13
const MAX_PREVIEW_CHARS = 275 ; // Number of characters to show for a given search result
14
14
const OUTPUT_INDEX = "lunr_index.js" ; // Index file
15
15
@@ -75,11 +75,11 @@ function buildIndex(docs) {
75
75
this . ref ( 'id' ) ;
76
76
for ( var i = 0 ; i < SEARCH_FIELDS . length ; i ++ ) {
77
77
this . field ( SEARCH_FIELDS [ i ] . slice ( 0 , 1 ) ) ;
78
- }
78
+ }
79
79
docs . forEach ( function ( doc ) {
80
- this . add ( doc ) ;
81
- } , this ) ;
82
- } ) ;
80
+ this . add ( doc ) ;
81
+ } , this ) ;
82
+ } ) ;
83
83
return idx ;
84
84
}
85
85
@@ -112,14 +112,14 @@ function main() {
112
112
}
113
113
var idx = buildIndex ( docs ) ;
114
114
var previews = buildPreviews ( docs ) ;
115
- var js = "const LUNR_DATA = " + JSON . stringify ( idx ) + ";\n" +
116
- "const PREVIEW_LOOKUP = " + JSON . stringify ( previews ) + ";" ;
117
- fs . writeFile ( OUTPUT_INDEX , js , function ( err ) {
118
- if ( err ) {
115
+ var js = "const LUNR_DATA = " + JSON . stringify ( idx ) + ";\n" +
116
+ "const PREVIEW_LOOKUP = " + JSON . stringify ( previews ) + ";" ;
117
+ fs . writeFile ( OUTPUT_INDEX , js , function ( err ) {
118
+ if ( err ) {
119
119
return console . log ( err ) ;
120
120
}
121
121
console . log ( "Index saved as " + OUTPUT_INDEX ) ;
122
- } ) ;
122
+ } ) ;
123
123
}
124
124
125
125
main ( ) ;
0 commit comments