function buildDocsIndex(dataPath, indexPath, done) {
  dataPath = dataPath || `${config.docsLocalPath}/search-data.json`;
  indexPath = indexPath || `${config.docsLocalPath}/search-index.json`;

  const documents = JSON.parse(fs.readFileSync(dataPath));

  // Generate index
  const idx = lunr(function () {
    this.ref('id');
    this.field('title');

    documents.forEach(function (doc) {
      this.add(doc);
    }, this);
  });

  const searchIndex = JSON.stringify(idx);

  // Save search index
  fs.writeFileSync(indexPath, searchIndex);

  done();
}
// Generates a search index for the documentation.
Generates a search index for the documentation.
Generates a search index for the documentation .
function buildDocsIndex(dataPath, indexPath, done) {
  dataPath = dataPath || `${config.docsLocalPath}/search-data.json`;
  indexPath = indexPath || `${config.docsLocalPath}/search-index.json`;
  const documents = JSON.parse(fs.readFileSync(dataPath));
  const idx = lunr(function () {
    this.ref('id');
    this.field('title');
    documents.forEach(function (doc) {
      this.add(doc);
    }, this);
  });
  const searchIndex = JSON.stringify(idx);
  fs.writeFileSync(indexPath, searchIndex);
  done();
}
function buildDocsIndex ( dataPath , indexPath , done ) { dataPath = dataPath || ` ${ config . docsLocalPath } ` ; indexPath = indexPath || ` ${ config . docsLocalPath } ` ; const documents = JSON . parse ( fs . readFileSync ( dataPath ) ) ; const idx = lunr ( function ( ) { this . ref ( 'id' ) ; this . field ( 'title' ) ; documents . forEach ( function ( doc ) { this . add ( doc ) ; } , this ) ; } ) ; const searchIndex = JSON . stringify ( idx ) ; fs . writeFileSync ( indexPath , searchIndex ) ; done ( ) ; }
Generates a search index for the documentation.
Generates a search index for the documentation .
// Generate index // Save search index