feat(aio): update metatags to control search engine crawling (#21665)
The `<meta name="robots" content="noindex">` tag is used to indicate to search engine crawlers that they should not index the current page. This is set dynamically by the the document viewer component to ensure that 404 and other erroring pages are not added to the search index. This relies upon the idea that the crawling bot will run the JS and wait to see if this meta tag has been added or not. Since we believe that the `googebot` will do this, we also pre-emptively add a hard-coded noindex tag specifically for this bot, so that if anything else fails in bootstrapping the app, the failed page will not be added to the index. Closes #21317 PR Close #21665
This commit is contained in:

committed by
Misko Hevery

parent
0b38a039d0
commit
88045a5050
@ -1,5 +1,5 @@
|
||||
import { Component, ComponentRef, NgModule, ViewChild } from '@angular/core';
|
||||
import { Title } from '@angular/platform-browser';
|
||||
import { Title, Meta } from '@angular/platform-browser';
|
||||
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
|
||||
@ -51,6 +51,11 @@ export class MockTitle {
|
||||
setTitle = jasmine.createSpy('Title#reset');
|
||||
}
|
||||
|
||||
export class MockMeta {
|
||||
addTag = jasmine.createSpy('Meta#addTag');
|
||||
removeTag = jasmine.createSpy('Meta#removeTag');
|
||||
}
|
||||
|
||||
export class MockTocService {
|
||||
genToc = jasmine.createSpy('TocService#genToc');
|
||||
reset = jasmine.createSpy('TocService#reset');
|
||||
@ -65,6 +70,7 @@ export class MockTocService {
|
||||
{ provide: Logger, useClass: MockLogger },
|
||||
{ provide: EmbedComponentsService, useClass: MockEmbedComponentsService },
|
||||
{ provide: Title, useClass: MockTitle },
|
||||
{ provide: Meta, useClass: MockMeta },
|
||||
{ provide: TocService, useClass: MockTocService },
|
||||
],
|
||||
})
|
||||
|
Reference in New Issue
Block a user