Skip to content

Commit

Permalink
change the build js to support cn
Browse files Browse the repository at this point in the history
  • Loading branch information
RenTonyHK committed Nov 19, 2018
1 parent 5a47fe1 commit c543d21
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions lib/nodejs/search/build.js
Expand Up @@ -38,12 +38,14 @@ module.exports = function build(ctx) {
this.field('title');
this.field('body');
documents.forEach(function(doc) {
console.log('***doc***');
console.log(doc);
this.add(doc);
}, this);
});
const hrend = process.hrtime(hrstart);
logger.debug(`Search index was built in ${hrend[0]}s, ${(hrend[1] / 1000000).toFixed()}ms`);
console.log(`Search index was built in ${hrend[0]}s, ${(hrend[1] / 1000000).toFixed()}ms`);

return {
index,
store,
Expand Down Expand Up @@ -79,9 +81,8 @@ const PagesIndexer = {
}

const items = pages.filter((page) => {

const ext = page.source.split('.').pop().toLowerCase();
console.log('page.content');
console.log(page.content);
return page.path &&
page.content &&
page.search !== 'exclude' &&
Expand All @@ -98,6 +99,7 @@ const PagesIndexer = {
}

const documents = items.reduce((acc, page) => {

acc.push({
id: page.path,
title: page.title,
Expand All @@ -106,6 +108,7 @@ const PagesIndexer = {
});

const $ = cheerio.load(page.content);
/*
$('h1,h2').each(function() {
const elem = $(this);
const anchorPagePath = `${page.path}#${elem.attr('id')}`;
Expand All @@ -117,14 +120,17 @@ const PagesIndexer = {
});
body = body.join(' ');
//console.log(body);
//console.log('***h1,h2****');
//console.log(sanitize(body));
acc.push({
id: `${page.path}#${elem.attr('id')}`,
title: sanitize(elem.html()),
body: sanitize(body),
path: urlFor(ctx.rootPath, anchorPagePath)
});
});
});*/
return acc;
}, []);

Expand Down

0 comments on commit c543d21

Please sign in to comment.