Skip to content

Commit

Permalink
feat(doc): reverse of docs list (#4912)
Browse files Browse the repository at this point in the history
  • Loading branch information
Domainv authored and valorkin committed Dec 12, 2018
1 parent 4a4dd89 commit f17459f
Showing 1 changed file with 22 additions and 7 deletions.
29 changes: 22 additions & 7 deletions demo/src/app/common/top-menu/top-menu.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@ export class TopMenuComponent implements AfterViewInit {
appUrl: string;
appHash: string;
currentVersion: string;
previousDocs: string[] = [];

previousDocs: {
url: string;
version: string;
unprefixedUrl: string;
}[] = [];

isLocalhost = false;
needPrefix = false;

Expand All @@ -23,18 +29,27 @@ export class TopMenuComponent implements AfterViewInit {
this.needPrefix = location.pathname !== '/';

this.appUrl = location.protocol + '//' + location.hostname + (this.isLocalhost ? ':' + location.port + '/' : '/');
this.http.get<any>('assets/json/versions.json').subscribe(data => {
this.previousDocs = data;
});
this.http.get<{ version: string }>('assets/json/current-version.json').subscribe(data => {
this.currentVersion = data.version;
});

this.http.get<any>('assets/json/versions.json')
.subscribe((data: { url: string; version: string; unprefixedUrl: string }[]) => {
this.previousDocs.push(data[0]);
this.previousDocs = this.previousDocs
.concat(data.reverse())
.slice(0, -1);
});

this.http.get<{ version: string }>('assets/json/current-version.json')
.subscribe((data: { version: string }) => {
this.currentVersion = data.version;
});
}

const getUrl = (router: Router) => {
const indexOfHash = router.routerState.snapshot.url.indexOf('#');

return router.routerState.snapshot.url.slice(0, indexOfHash);
};

let _prev = getUrl(this.router);
this.router.events.subscribe((event: any) => {
const _cur = getUrl(this.router);
Expand Down

0 comments on commit f17459f

Please sign in to comment.