mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
docs(docs-infra): add search via queryparam all adev routes (#57567)
add search via a queryparam (?search=query) on all adev routes PR Close #57567
This commit is contained in:
committed by
Jessica Janiuk
parent
f7a0b8eede
commit
4e478af90f
@@ -0,0 +1,28 @@
|
||||
import {Component, effect, inject, model, WritableSignal} from '@angular/core';
|
||||
import {IS_SEARCH_DIALOG_OPEN, Search} from '@angular/docs';
|
||||
import {RouterOutlet} from '@angular/router';
|
||||
|
||||
@Component({
|
||||
standalone: true,
|
||||
selector: 'adev-main',
|
||||
imports: [RouterOutlet],
|
||||
template: `<router-outlet />`,
|
||||
})
|
||||
export default class MainComponent {
|
||||
private readonly displaySearchDialog: WritableSignal<boolean> = inject(IS_SEARCH_DIALOG_OPEN);
|
||||
private readonly searchService = inject(Search);
|
||||
search = model<string | undefined>('');
|
||||
|
||||
constructor() {
|
||||
effect(
|
||||
() => {
|
||||
const search = this.search();
|
||||
if (search !== undefined) {
|
||||
this.displaySearchDialog.set(true);
|
||||
this.searchService.updateSearchQuery(search);
|
||||
}
|
||||
},
|
||||
{allowSignalWrites: true},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,7 @@ import {Route} from '@angular/router';
|
||||
import {DefaultPage, PagePrefix} from './core/enums/pages';
|
||||
import {SUB_NAVIGATION_DATA} from './sub-navigation-data';
|
||||
import {mapApiManifestToRoutes} from './features/references/helpers/manifest.helper';
|
||||
import MainComponent from './main.component';
|
||||
|
||||
// Docs navigation data contains routes which navigates to /tutorials pages, in
|
||||
// that case we should load Tutorial component
|
||||
@@ -236,6 +237,7 @@ const REDIRECT_ROUTES: Route[] = [
|
||||
export const routes: Route[] = [
|
||||
{
|
||||
path: '',
|
||||
component: MainComponent,
|
||||
children: [
|
||||
{
|
||||
path: '',
|
||||
|
||||
Reference in New Issue
Block a user