diff --git a/aio/tools/transforms/angular-api-package/processors/computeApiBreadCrumbs.js b/aio/tools/transforms/angular-api-package/processors/computeApiBreadCrumbs.js index c813b11c9c..62eb6c2225 100644 --- a/aio/tools/transforms/angular-api-package/processors/computeApiBreadCrumbs.js +++ b/aio/tools/transforms/angular-api-package/processors/computeApiBreadCrumbs.js @@ -1,16 +1,15 @@ -module.exports = function computeApiBreadCrumbs(EXPORT_DOC_TYPES) { +module.exports = function computeApiBreadCrumbs(API_DOC_TYPES_TO_RENDER) { return { $runAfter: ['paths-computed'], $runBefore: ['rendering-docs'], $process(docs) { // Compute the breadcrumb for each doc by processing its containers docs.forEach(doc => { - if (EXPORT_DOC_TYPES.indexOf(doc.docType) !== -1) { - doc.breadCrumbs = [ - { text: 'API', path: '/api' }, - { text: '@angular/' + doc.moduleDoc.id, path: doc.moduleDoc.path }, - { text: doc.name, path: doc.path } - ]; + if (API_DOC_TYPES_TO_RENDER.indexOf(doc.docType) !== -1) { + doc.breadCrumbs = []; + doc.breadCrumbs.push({ text: 'API', path: '/api' }); + if (doc.moduleDoc) doc.breadCrumbs.push({ text: '@angular/' + doc.moduleDoc.id, path: doc.moduleDoc.path }); + doc.breadCrumbs.push({ text: doc.name, path: doc.path }); } }); } diff --git a/aio/tools/transforms/angular-api-package/processors/computeApiBreadCrumbs.spec.js b/aio/tools/transforms/angular-api-package/processors/computeApiBreadCrumbs.spec.js index 7e3aba0c96..03bc24e426 100644 --- a/aio/tools/transforms/angular-api-package/processors/computeApiBreadCrumbs.spec.js +++ b/aio/tools/transforms/angular-api-package/processors/computeApiBreadCrumbs.spec.js @@ -13,14 +13,15 @@ describe('angular-api-package: computeApiBreadCrumbs processor', () => { expect(processor.$runBefore).toEqual(['rendering-docs']); }); - it('should attach a breadCrumbs property to each of the EXPORT_DOC_TYPES docs', () => { - const EXPORT_DOC_TYPES = ['class', 'interface']; - const processor = processorFactory(EXPORT_DOC_TYPES); + it('should attach a breadCrumbs property to each of the API_DOC_TYPES_TO_RENDER docs', () => { + const API_DOC_TYPES_TO_RENDER = ['class', 'interface', 'module']; + const processor = processorFactory(API_DOC_TYPES_TO_RENDER); const docs = [ { docType: 'class', name: 'ClassA', path: 'module-1/class-a', moduleDoc: { id: 'moduleOne', path: 'module-1' } }, { docType: 'interface', name: 'InterfaceB', path: 'module-2/interface-b', moduleDoc: { id: 'moduleTwo', path: 'module-2' } }, { docType: 'guide', name: 'Guide One', path: 'guide/guide-1' }, + { docType: 'module', name: 'testing', id: 'http/testing', path: 'http/testing' }, ]; processor.$process(docs); @@ -35,5 +36,9 @@ describe('angular-api-package: computeApiBreadCrumbs processor', () => { { text: 'InterfaceB', path: 'module-2/interface-b' }, ]); expect(docs[2].breadCrumbs).toBeUndefined(); + expect(docs[3].breadCrumbs).toEqual([ + { text: 'API', path: '/api' }, + { text: 'testing', path: 'http/testing' }, + ]); }); });