docs: 添加外部导航链接

This commit is contained in:
Zhicheng Wang 2018-09-11 12:57:12 +08:00
parent 1150e9b6b7
commit ad4a674b65
3 changed files with 16 additions and 1 deletions

View File

@ -545,6 +545,16 @@
"tooltip": "关于 Angular 中类和值的详细信息。", "tooltip": "关于 Angular 中类和值的详细信息。",
"url": "api" "url": "api"
}, },
{
"title": "互助问答",
"tooltip": "github 上的中文互助问答区",
"url": "https://github.com/ng-docs/ng-docs.github.io/issues"
},
{
"title": "Material 组件库",
"tooltip": "Angular Material 组件库的中文文档",
"url": "https://material.angular.cn"
},
{ {
"url": "guide/change-log", "url": "guide/change-log",
"title": "Change Log", "title": "Change Log",

View File

@ -1,7 +1,8 @@
<div *ngIf="!node.children"> <div *ngIf="!node.children">
<a href="{{node.url}}" [ngClass]="classes" title="{{node.tooltip}}" <a href="{{node.url}}" [ngClass]="classes" title="{{node.tooltip}}"
class="vertical-menu-item"> class="vertical-menu-item" style="position: relative" [target]="isExternalUrl(node.url)?'_blank':'_self'">
{{node.title}} {{node.title}}
<mat-icon *ngIf="isExternalUrl(node.url)">open_in_new</mat-icon>
</a> </a>
</div> </div>

View File

@ -47,4 +47,8 @@ export class NavItemComponent implements OnChanges {
this.isExpanded = !this.isExpanded; this.isExpanded = !this.isExpanded;
this.setClasses(); this.setClasses();
} }
isExternalUrl(url: string): boolean {
return /^https?:/.test(url);
}
} }