Skip to content

Commit

Permalink
fix(daffio): sidebars not registered on child docs routes (#3444)
Browse files Browse the repository at this point in the history
  • Loading branch information
griest024 authored Jan 15, 2025
1 parent 6020044 commit 2017cc8
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 34 deletions.
79 changes: 45 additions & 34 deletions apps/daffio/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,53 +18,64 @@ import { StoreModule } from '@ngrx/store';
import { StoreDevtoolsModule } from '@ngrx/store-devtools';

import { DAFF_THEME_INITIALIZER } from '@daffodil/design';
import { provideDaffRouterActivatedRoute } from '@daffodil/router';
import {
provideDaffRouterActivatedRoute,
provideDaffRouterDataServiceConfig,
} from '@daffodil/router';
import { provideDaffSeoRouterSchema } from '@daffodil/seo/router';

import { AppRoutingModule } from './app-routing.module';
import { DaffioAppComponent } from './app.component';
import { environment } from '../environments/environment';
import { DaffioMarketingFooterComponentModule } from './core/footer/marketing-footer/marketing-footer.module';
import { DaffioSimpleFooterComponentModule } from './core/footer/simple-footer/simple-footer.module';
import { daffioRouterDataServiceConfig } from './core/router/data-service-config';
import { DaffioSidebarFooterComponentModule } from './core/sidebar/components/sidebar-footer/sidebar-footer.module';
import { DaffioSidebarHeaderComponentModule } from './core/sidebar/components/sidebar-header/sidebar-header.module';
import { TemplateModule } from './core/template/template.module';

@NgModule({ declarations: [
DaffioAppComponent,
],
bootstrap: [
DaffioAppComponent,
], imports: [BrowserModule,
BrowserAnimationsModule,
StoreModule.forRoot({}),
EffectsModule.forRoot(),
AppRoutingModule,
DaffioSidebarHeaderComponentModule,
DaffioSidebarFooterComponentModule,
DaffioSimpleFooterComponentModule,
DaffioMarketingFooterComponentModule,
//Make sure this loads after Router and Store
StoreRouterConnectingModule.forRoot({ serializer: FullRouterStateSerializer,
@NgModule({
declarations: [
DaffioAppComponent,
],
bootstrap: [
DaffioAppComponent,
],
imports: [
BrowserModule,
BrowserAnimationsModule,
StoreModule.forRoot({}),
EffectsModule.forRoot(),
AppRoutingModule,
DaffioSidebarHeaderComponentModule,
DaffioSidebarFooterComponentModule,
DaffioSimpleFooterComponentModule,
DaffioMarketingFooterComponentModule,
//Make sure this loads after Router and Store
StoreRouterConnectingModule.forRoot({ serializer: FullRouterStateSerializer,
/*
They stateKey defines the name of the state used by the router-store reducer.
This matches the key defined in the map of reducers
*/
stateKey: 'router' }),
StoreDevtoolsModule.instrument({
maxAge: 25, // Retains last 25 states
logOnly: environment.production, // Restrict extension to log-only mode
connectInZone: true,
}),
TemplateModule,
ServiceWorkerModule.register('ngsw-worker.js', { enabled: environment.production })], providers: [
DAFF_THEME_INITIALIZER,
{
provide: APP_ID,
useValue: 'serverApp',
},
provideDaffRouterActivatedRoute(),
provideDaffSeoRouterSchema(),
provideHttpClient(withInterceptorsFromDi()),
] })
stateKey: 'router' }),
StoreDevtoolsModule.instrument({
maxAge: 25, // Retains last 25 states
logOnly: environment.production, // Restrict extension to log-only mode
connectInZone: true,
}),
TemplateModule,
ServiceWorkerModule.register('ngsw-worker.js', { enabled: environment.production }),
],
providers: [
DAFF_THEME_INITIALIZER,
{
provide: APP_ID,
useValue: 'serverApp',
},
provideDaffRouterActivatedRoute(),
provideDaffSeoRouterSchema(),
provideHttpClient(withInterceptorsFromDi()),
provideDaffRouterDataServiceConfig(daffioRouterDataServiceConfig),
],
})
export class AppModule {}
10 changes: 10 additions & 0 deletions apps/daffio/src/app/core/router/data-service-config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { daffDictAssignMerger } from '@daffodil/core';
import { DaffRouterDataServiceConfig } from '@daffodil/router';

import { DaffioRoute } from './route.type';

export const daffioRouterDataServiceConfig: DaffRouterDataServiceConfig<DaffioRoute['data']> = {
mergeStrategy: {
daffioSidebars: daffDictAssignMerger,
},
};

0 comments on commit 2017cc8

Please sign in to comment.