@@ -5,11 +5,11 @@ var cheerio = require("cheerio");
55
66
77// 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
99// Valid search fields: "title", "description", "keywords", "body"
1010const SEARCH_FIELDS = [ "description" , "keywords" , "body" ] ;
1111const 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" ] ;
1313const MAX_PREVIEW_CHARS = 275 ; // Number of characters to show for a given search result
1414const OUTPUT_INDEX = "lunr_index.js" ; // Index file
1515
@@ -75,11 +75,11 @@ function buildIndex(docs) {
7575 this . ref ( 'id' ) ;
7676 for ( var i = 0 ; i < SEARCH_FIELDS . length ; i ++ ) {
7777 this . field ( SEARCH_FIELDS [ i ] . slice ( 0 , 1 ) ) ;
78- }
78+ }
7979 docs . forEach ( function ( doc ) {
80- this . add ( doc ) ;
81- } , this ) ;
82- } ) ;
80+ this . add ( doc ) ;
81+ } , this ) ;
82+ } ) ;
8383 return idx ;
8484}
8585
@@ -112,14 +112,14 @@ function main() {
112112 }
113113 var idx = buildIndex ( docs ) ;
114114 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 ) {
119119 return console . log ( err ) ;
120120 }
121121 console . log ( "Index saved as " + OUTPUT_INDEX ) ;
122- } ) ;
122+ } ) ;
123123}
124124
125125main ( ) ;
0 commit comments