Skip to content

Commit 4cf59a7

Browse files
committed
docs: redirect testing, drag-drop docs to adev
1 parent 931ac3c commit 4cf59a7

File tree

3 files changed

+71
-0
lines changed

3 files changed

+71
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/**
2+
* @license
3+
* Copyright Google LLC All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.dev/license
7+
*/
8+
9+
import {Injectable} from '@angular/core';
10+
import {ActivatedRouteSnapshot, Resolve} from '@angular/router';
11+
12+
@Injectable({providedIn: 'root'})
13+
export class ExternalRedirectResolver implements Resolve<void> {
14+
resolve(route: ActivatedRouteSnapshot): void {
15+
const targetUrl = route.data['external-redirect'];
16+
if (targetUrl) {
17+
window.location.href = targetUrl;
18+
}
19+
}
20+
}

docs/src/app/routes.ts

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
*/
88

99
import {Routes} from '@angular/router';
10+
import {ExternalRedirectResolver} from './external-redirect-resolver';
1011
import {CanActivateComponentSidenav} from './pages/component-sidenav/component-sidenav-can-load-guard';
1112

1213
export const MATERIAL_DOCS_ROUTES: Routes = [
@@ -25,6 +26,55 @@ export const MATERIAL_DOCS_ROUTES: Routes = [
2526
// Since https://github.com/angular/components/pull/9574, the cdk-table guide became the overview
2627
// document for the cdk table. To avoid any dead / broken links, we redirect to the new location.
2728
{path: 'guide/cdk-table', redirectTo: '/cdk/table/overview'},
29+
// Component harness, drag & drop docs have moved to angular.dev
30+
{
31+
path: 'cdk/testing',
32+
// We need to load some component, but really we just want to stay on the current page while we
33+
// wait for the external redirect.
34+
loadComponent: () => new Promise(() => {}) as any,
35+
data: {'external-redirect': 'https://angular.dev/guide/testing/component-harnesses-overview'},
36+
resolve: {reddirect: ExternalRedirectResolver},
37+
},
38+
{
39+
path: 'cdk/testing/api',
40+
// We need to load some component, but really we just want to stay on the current page while we
41+
// wait for the external redirect.
42+
loadComponent: () => new Promise(() => {}) as any,
43+
data: {'external-redirect': 'https://angular.dev/api#angular_cdk_testing'},
44+
resolve: {reddirect: ExternalRedirectResolver},
45+
},
46+
{
47+
path: 'cdk/testing/:tab',
48+
// We need to load some component, but really we just want to stay on the current page while we
49+
// wait for the external redirect.
50+
loadComponent: () => new Promise(() => {}) as any,
51+
data: {'external-redirect': 'https://angular.dev/guide/testing/component-harnesses-overview'},
52+
resolve: {reddirect: ExternalRedirectResolver},
53+
},
54+
{
55+
path: 'cdk/drag-drop',
56+
// We need to load some component, but really we just want to stay on the current page while we
57+
// wait for the external redirect.
58+
loadComponent: () => new Promise(() => {}) as any,
59+
data: {'external-redirect': 'https://angular.dev/guide/drag-drop'},
60+
resolve: {reddirect: ExternalRedirectResolver},
61+
},
62+
{
63+
path: 'cdk/drag-drop/api',
64+
// We need to load some component, but really we just want to stay on the current page while we
65+
// wait for the external redirect.
66+
loadComponent: () => new Promise(() => {}) as any,
67+
data: {'external-redirect': 'https://angular.dev/api#angular_cdk_drag-drop'},
68+
resolve: {reddirect: ExternalRedirectResolver},
69+
},
70+
{
71+
path: 'cdk/drag-drop/:tab',
72+
// We need to load some component, but really we just want to stay on the current page while we
73+
// wait for the external redirect.
74+
loadComponent: () => new Promise(() => {}) as any,
75+
data: {'external-redirect': 'https://angular.dev/guide/drag-drop'},
76+
resolve: {reddirect: ExternalRedirectResolver},
77+
},
2878
// In v19, the theming system became based on system variables and the mat.theme mixin.
2979
// The following guides were consolidated into the main theming guide, which redirects
3080
// users to v18 docs if they are looking for this content.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"build-docs-content": "node --no-warnings=ExperimentalWarning --loader ts-node/esm/transpile-only ./scripts/build-docs-content-main.mts",
2222
"build-and-check-release-output": "node --no-warnings=ExperimentalWarning --loader ts-node/esm/transpile-only scripts/build-and-check-release-output.mts",
2323
"dev-app": "ibazel run //src/dev-app:devserver",
24+
"docs-app": "ibazel run //docs:serve",
2425
"universal-app": "bazel run //src/universal-app:server",
2526
"test": "node ./scripts/run-component-tests.js",
2627
"test-local": "pnpm -s test --local",

0 commit comments

Comments
 (0)