fix(aio): allow empty titles for contents pages
Now if you specifically provide an empty `@title` tag for a contents file, the doc-gen will not complain and the browser will just display a reasonable default.
This commit is contained in:

committed by
Pete Bacon Darwin

parent
4624406ce8
commit
51098c4f86
@ -272,6 +272,14 @@ describe('AppComponent', () => {
|
||||
fixture.detectChanges();
|
||||
expect(titleService.setTitle).toHaveBeenCalledWith('Angular - Pipes');
|
||||
});
|
||||
|
||||
it('should update the document title, with a default value if the document has no title', () => {
|
||||
const titleService = TestBed.get(Title);
|
||||
spyOn(titleService, 'setTitle');
|
||||
locationService.go('file-not-found');
|
||||
fixture.detectChanges();
|
||||
expect(titleService.setTitle).toHaveBeenCalledWith('Angular');
|
||||
});
|
||||
});
|
||||
|
||||
describe('autoScrolling', () => {
|
||||
@ -424,12 +432,18 @@ class TestHttp {
|
||||
"contents": "<h1>Test Doc</h1>"
|
||||
};
|
||||
|
||||
fileNotFoundDoc = {
|
||||
"title": "",
|
||||
"contents": "Page not found"
|
||||
};
|
||||
|
||||
// get = jasmine.createSpy('get').and.callFake((url: string) => { ... });
|
||||
get(url: string) {
|
||||
const json =
|
||||
/navigation.json/.test(url) ? this.navJson :
|
||||
/api/.test(url) ? this.apiDoc :
|
||||
/pipes/.test(url) ? this.pipesDoc :
|
||||
/file-not-found/.test(url) ? this.fileNotFoundDoc :
|
||||
this.testDoc;
|
||||
return of({ json: () => json });
|
||||
}
|
||||
|
@ -150,6 +150,10 @@ export class AppComponent implements OnInit {
|
||||
}
|
||||
|
||||
setDocumentTitle(title) {
|
||||
this.titleService.setTitle(`Angular - ${title}`);
|
||||
if (title.trim()) {
|
||||
this.titleService.setTitle(`Angular - ${title}`);
|
||||
} else {
|
||||
this.titleService.setTitle('Angular');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user