gitbook-plugin-search
Advanced tools
Comparing version 1.0.2 to 1.1.0
13
index.js
@@ -14,2 +14,5 @@ var lunr = require('lunr'); | ||
var searchIndexEnabled = true; | ||
var indexSize = 0; | ||
module.exports = { | ||
@@ -29,3 +32,4 @@ book: { | ||
"page": function(page) { | ||
if (this.options.generator != 'website') return page; | ||
if (this.options.generator != 'website' || !searchIndexEnabled) return page; | ||
var maxIndexSize = this.config.get('pluginsConfig.search.maxIndexSize') || this.config.get('search.maxIndexSize') | ||
@@ -40,2 +44,9 @@ this.log.debug.ln('index page', page.path); | ||
indexSize = indexSize + text.length; | ||
if (indexSize > maxIndexSize) { | ||
this.log.warn.ln("search index is too big, indexing is now disabled"); | ||
searchIndexEnabled = false; | ||
return page; | ||
} | ||
// Add to index | ||
@@ -42,0 +53,0 @@ searchIndex.add({ |
@@ -5,5 +5,5 @@ { | ||
"main": "index.js", | ||
"version": "1.0.2", | ||
"version": "1.1.0", | ||
"engines": { | ||
"gitbook": ">=2.4.0" | ||
"gitbook": ">=2.5.0" | ||
}, | ||
@@ -28,3 +28,12 @@ "dependencies": { | ||
"prepublish": "cp node_modules/lunr/lunr.min.js ./assets/lunr.min.js;lessc ./less/search.less > ./assets/search.css" | ||
}, | ||
"gitbook": { | ||
"properties": { | ||
"maxIndexSize": { | ||
"type": "number", | ||
"title": "Limit size for the index", | ||
"default": 1000000 | ||
} | ||
} | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
33614
200