build(aio): the the captured h1 as the title for the search index

If there is no title already provided, use the one captured from the renderedContent.
This commit is contained in:
Peter Bacon Darwin
2017-05-30 22:24:54 +03:00
committed by Pete Bacon Darwin
parent 89f317915d
commit dfbbbb5e3e
3 changed files with 39 additions and 9 deletions

View File

@ -22,8 +22,8 @@ module.exports = function generateKeywordsProcessor(log, readFilesProcessor) {
propertiesToIgnore: {},
outputFolder: {presence: true}
},
$runAfter: ['paths-computed'],
$runBefore: ['rendering-docs'],
$runAfter: ['postProcessHtml'],
$runBefore: ['writing-files'],
$process: function(docs) {
// Keywords to ignore
@ -103,9 +103,10 @@ module.exports = function generateKeywordsProcessor(log, readFilesProcessor) {
}
});
doc.searchTitle = doc.searchTitle || doc.title || doc.vFile && doc.vFile.title || doc.name;
doc.searchTerms = {
titleWords: extractTitleWords(doc.title || doc.name),
titleWords: extractTitleWords(doc.searchTitle),
keywords: words.sort().join(' '),
members: members.sort().join(' ')
};
@ -115,16 +116,16 @@ module.exports = function generateKeywordsProcessor(log, readFilesProcessor) {
var searchData =
filteredDocs.filter(function(page) { return page.searchTerms; }).map(function(page) {
return Object.assign(
{path: page.path, title: page.searchTitle || page.name || page.title, type: page.docType}, page.searchTerms);
{path: page.path, title: page.searchTitle, type: page.docType}, page.searchTerms);
});
docs.push({
docType: 'json-doc',
id: 'search-data-json',
template: 'json-doc.template.json',
path: this.outputFolder + '/search-data.json',
outputPath: this.outputFolder + '/search-data.json',
data: searchData
data: searchData,
renderedContent: JSON.stringify(searchData)
});
}
};