build(aio): add version into navigation.json

The navigation.json is now passed through the dgeni pipeline.
The source file has been moved to `aio/content/navigation.json`
but the generated file will now appear where the original source file
was found, `aio/src/content/navigation.json`.

Everything inside `aio/src/content` is now generated and ignored by git.

The `processNavigationMap` processor in this commit adds the current version
information to the navigation.json file and verifies the relative urls in
the file map to real documents.

The navigationService exposes the versionInfo as an observable, which the
AppComponent renders at the top of the sidenav.
This commit is contained in:
Peter Bacon Darwin 2017-03-21 11:27:53 +00:00 committed by Miško Hevery
parent 90f699fdcf
commit a9e91115bf
2 changed files with 5 additions and 5 deletions

View File

@ -135,12 +135,11 @@ describe('NavigationService', () => {
const backend = injector.get(ConnectionBackend);
backend.connectionsArray[0].mockRespond(createResponse({
['__versionInfo']: { raw: '4.0.0' }
__versionInfo: { raw: '4.0.0' }
}));
});
it('should extract the version info', () => {
const backend = injector.get(ConnectionBackend);
expect(versionInfo).toEqual({ raw: '4.0.0' });
});
});

View File

@ -12,7 +12,8 @@ import { LocationService } from 'app/shared/location.service';
import { NavigationNode } from './navigation-node';
export { NavigationNode } from './navigation-node';
export type NavigationResponse = {'__versionInfo': VersionInfo } & { [name: string]: NavigationNode[] };
export type NavigationResponse = {__versionInfo: VersionInfo } & { [name: string]: NavigationNode[]|VersionInfo };
export interface NavigationViews {
[name: string]: NavigationNode[];
@ -86,12 +87,12 @@ export class NavigationService {
}
private getVersionInfo(navigationInfo: Observable<NavigationResponse>) {
const versionInfo = navigationInfo.map(response => response['__versionInfo']).publishReplay(1);
const versionInfo = navigationInfo.map(response => response.__versionInfo).publishReplay(1);
versionInfo.connect();
return versionInfo;
}
private getNavigationViews(navigationInfo: Observable<NavigationResponse>) {
private getNavigationViews(navigationInfo: Observable<NavigationResponse>): Observable<NavigationViews> {
const navigationViews = navigationInfo.map(response => unpluck(response, '__versionInfo')).publishReplay(1);
navigationViews.connect();
return navigationViews;