gitbook-plugin-search
Advanced tools
Comparing version 1.1.0 to 1.2.0
22
index.js
@@ -31,12 +31,11 @@ var lunr = require('lunr'); | ||
"page": function(page) { | ||
if (this.options.generator != 'website' || !searchIndexEnabled) return page; | ||
var maxIndexSize = this.config.get('pluginsConfig.search.maxIndexSize') || this.config.get('search.maxIndexSize') | ||
if (this.output.name != 'website' || !searchIndexEnabled) return page; | ||
var text, maxIndexSize; | ||
maxIndexSize = this.config.get('pluginsConfig.search.maxIndexSize') || this.config.get('search.maxIndexSize'); | ||
this.log.debug.ln('index page', page.path); | ||
// Extract HTML | ||
var html = _.pluck(page.sections, 'content').join(' '); | ||
// Transform as TEXT | ||
var text = html.replace(/(<([^>]+)>)/ig, ''); | ||
text = page.content.replace(/(<([^>]+)>)/ig, ''); | ||
@@ -52,4 +51,4 @@ indexSize = indexSize + text.length; | ||
searchIndex.add({ | ||
url: this.contentLink(page.path), | ||
title: page.progress.current.title, | ||
url: this.output.toURL(page.path), | ||
title: page.title, | ||
body: text | ||
@@ -63,9 +62,6 @@ }); | ||
"finish": function() { | ||
if (this.options.generator != 'website') return; | ||
if (this.output.name != 'website') return; | ||
this.log.debug.ln('write search index'); | ||
fs.writeFileSync( | ||
path.join(this.options.output, "search_index.json"), | ||
JSON.stringify(searchIndex) | ||
); | ||
return this.output.writeFile('search_index.json', JSON.stringify(searchIndex)); | ||
} | ||
@@ -72,0 +68,0 @@ } |
@@ -5,5 +5,5 @@ { | ||
"main": "index.js", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"engines": { | ||
"gitbook": ">=2.5.0" | ||
"gitbook": ">=3.0.0-pre.0" | ||
}, | ||
@@ -10,0 +10,0 @@ "dependencies": { |
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
33467
196