Skip to content

Commit 1542881

Browse files
committed
build: link directly to drag&drop on adev
Currently we have an internal router link that gets redirected to adev. This is likely bad for SEO since the bot may not follow the link. These changes use a link pointing directly to adev. Note that we have to keep the routing config in case users land on the page directly.
1 parent 2ad3866 commit 1542881

File tree

4 files changed

+41
-23
lines changed

4 files changed

+41
-23
lines changed

docs/src/app/pages/component-category-list/component-category-list.html

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,31 @@
66
@if (items.length > 0) {
77
<div class="docs-component-category-list">
88
@for (component of items; track component) {
9-
<a class="docs-component-category-list-item"
10-
[routerLink]="'/' + section + '/' + component.id">
11-
<div class="docs-component-category-list-card" matRipple>
12-
@if (section === 'components') {
13-
<img class="docs-component-category-list-card-image-wrapper"
14-
[src]="'../../../assets/screenshots/' + component.id + '.scene.png'"
15-
loading="lazy"
16-
alt=""
17-
role="presentation"
18-
aria-hidden="true">
19-
}
20-
<div class="docs-component-category-list-card-title">{{component.name}}</div>
21-
<div class="docs-component-category-list-card-summary">{{component.summary}}</div>
22-
</div>
23-
</a>
9+
@if (component.externalRedirect) {
10+
<a class="docs-component-category-list-item" [href]="component.externalRedirect">
11+
<ng-container [ngTemplateOutlet]="card" [ngTemplateOutletContext]="{component}"/>
12+
</a>
13+
} @else {
14+
<a class="docs-component-category-list-item"
15+
[routerLink]="'/' + section + '/' + component.id">
16+
<ng-container [ngTemplateOutlet]="card" [ngTemplateOutletContext]="{component}"/>
17+
</a>
18+
}
2419
}
2520
</div>
2621
}
22+
23+
<ng-template #card let-component="component">
24+
<div class="docs-component-category-list-card" matRipple>
25+
@if (section === 'components') {
26+
<img class="docs-component-category-list-card-image-wrapper"
27+
[src]="'../../../assets/screenshots/' + component.id + '.scene.png'"
28+
loading="lazy"
29+
alt=""
30+
role="presentation"
31+
aria-hidden="true">
32+
}
33+
<div class="docs-component-category-list-card-title">{{component.name}}</div>
34+
<div class="docs-component-category-list-card-summary">{{component.summary}}</div>
35+
</div>
36+
</ng-template>

docs/src/app/pages/component-category-list/component-category-list.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import {Component, OnDestroy, OnInit, inject} from '@angular/core';
1010
import {ActivatedRoute, RouterLink} from '@angular/router';
1111
import {MatRipple} from '@angular/material/core';
12+
import {NgTemplateOutlet} from '@angular/common';
1213
import {combineLatest, Subscription} from 'rxjs';
1314

1415
import {
@@ -24,7 +25,7 @@ import {ComponentPageTitle} from '../page-title/page-title';
2425
selector: 'app-component-category-list',
2526
templateUrl: './component-category-list.html',
2627
styleUrls: ['./component-category-list.scss'],
27-
imports: [NavigationFocus, RouterLink, MatRipple],
28+
imports: [NavigationFocus, RouterLink, MatRipple, NgTemplateOutlet],
2829
})
2930
export class ComponentCategoryList implements OnInit, OnDestroy {
3031
private readonly _docItems = inject(DocumentationItems);

docs/src/app/pages/component-sidenav/component-nav.html

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,17 @@
66
<div class="docs-component-viewer-nav-content">
77
<mat-nav-list>
88
@for (component of items; track component) {
9-
<a mat-list-item #link="routerLinkActive"
10-
[routerLink]="'/' + params?.section + '/' + component.id"
11-
[activated]="link.isActive"
12-
routerLinkActive="docs-component-viewer-sidenav-item-selected"
13-
[attr.aria-current]="link.isActive ? 'page': 'false'">
14-
{{component.name}}
15-
</a>
9+
@if (component.externalRedirect) {
10+
<a mat-list-item [href]="component.externalRedirect">{{component.name}}</a>
11+
} @else {
12+
<a mat-list-item #link="routerLinkActive"
13+
[routerLink]="'/' + params?.section + '/' + component.id"
14+
[activated]="link.isActive"
15+
routerLinkActive="docs-component-viewer-sidenav-item-selected"
16+
[attr.aria-current]="link.isActive ? 'page': 'false'">
17+
{{component.name}}
18+
</a>
19+
}
1620
}
1721
</mat-nav-list>
1822
</div>

docs/src/app/shared/documentation-items/documentation-items.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ export interface DocItem {
4040
additionalApiDocs?: AdditionalApiDoc[];
4141
/** Whether the doc item can display styling information. */
4242
hasStyling?: boolean;
43+
/** External URL to the item's docs. */
44+
externalRedirect?: string;
4345
}
4446

4547
export interface DocSection {
@@ -462,6 +464,7 @@ const DOCS: {[key: string]: DocItem[]} = {
462464
id: 'drag-drop',
463465
name: 'Drag and Drop',
464466
summary: 'Directives enabling drag-and-drop interactions',
467+
externalRedirect: 'https://angular.dev/guide/drag-drop',
465468
exampleSpecs: {
466469
prefix: 'cdk-drag-drop-',
467470
},

0 commit comments

Comments
 (0)