diff --git a/aio/src/app/search/interfaces.ts b/aio/src/app/search/interfaces.ts index 691a17bb7f..a43c17d211 100644 --- a/aio/src/app/search/interfaces.ts +++ b/aio/src/app/search/interfaces.ts @@ -9,6 +9,7 @@ export interface SearchResult { type: string; titleWords: string; keywords: string; + topics?: string; deprecated: boolean; } diff --git a/aio/src/app/search/search.worker.ts b/aio/src/app/search/search.worker.ts index 7c2f9623f6..635b90fb25 100644 --- a/aio/src/app/search/search.worker.ts +++ b/aio/src/app/search/search.worker.ts @@ -15,6 +15,7 @@ interface PageInfo { type: string; titleWords: string; keyWords: string; + topics?: string; } addEventListener('message', handleMessage); @@ -27,6 +28,7 @@ function createIndex(loadIndexFn: IndexLoader): lunr.Index { queryLexer.termSeparator = lunr.tokenizer.separator = /\s+/; return lunr(/** @this */function() { this.ref('path'); + this.field('topics', { boost: 15 }); this.field('titleWords', { boost: 10 }); this.field('headingWords', { boost: 5 }); this.field('members', { boost: 4 }); diff --git a/aio/tools/transforms/angular-base-package/index.js b/aio/tools/transforms/angular-base-package/index.js index 7a163afbe3..7642b2e020 100644 --- a/aio/tools/transforms/angular-base-package/index.js +++ b/aio/tools/transforms/angular-base-package/index.js @@ -45,6 +45,11 @@ module.exports = new Package('angular-base', [ .factory(require('./post-processors/add-image-dimensions')) .factory(require('./post-processors/auto-link-code')) + // Configure jsdoc-style tag parsing + .config(function(inlineTagProcessor) { + inlineTagProcessor.inlineTagDefinitions.push(require('./inline-tag-defs/custom-search-defs/')); + }) + .config(function(checkAnchorLinksProcessor) { // This is disabled here to prevent false negatives for the `docs-watch` task. // It is re-enabled in the main `angular.io-package` diff --git a/aio/tools/transforms/angular-base-package/inline-tag-defs/custom-search-defs/index.js b/aio/tools/transforms/angular-base-package/inline-tag-defs/custom-search-defs/index.js new file mode 100644 index 0000000000..048853a370 --- /dev/null +++ b/aio/tools/transforms/angular-base-package/inline-tag-defs/custom-search-defs/index.js @@ -0,0 +1,9 @@ +module.exports = { + name: 'searchKeywords', + description: 'A shorthand for creating elements with search terms. Usage: `{@searchKeywords term1 term2 termN }`', + handler: function(doc, tagName, tagDescription) { + doc.searchKeywords = tagDescription; + return doc; + } +}; + \ No newline at end of file diff --git a/aio/tools/transforms/angular-base-package/processors/generateKeywords.js b/aio/tools/transforms/angular-base-package/processors/generateKeywords.js index 07db2914ad..7cad35b0db 100644 --- a/aio/tools/transforms/angular-base-package/processors/generateKeywords.js +++ b/aio/tools/transforms/angular-base-package/processors/generateKeywords.js @@ -91,7 +91,8 @@ module.exports = function generateKeywordsProcessor(log, readFilesProcessor) { titleWords: tokenize(doc.searchTitle).join(' '), headingWords: headingWords.sort().join(' '), keywords: words.sort().join(' '), - members: members.sort().join(' ') + members: members.sort().join(' '), + topics: doc.searchKeywords }; });