@@ -3,7 +3,7 @@ import { ActivatedRoute, Router } from '@angular/router';
33import { isPlatformServer } from '@angular/common' ;
44
55import { Observable } from 'rxjs' ;
6- import { map , take } from 'rxjs/operators' ;
6+ import { map } from 'rxjs/operators' ;
77
88import { ItemDataService } from '../../core/data/item-data.service' ;
99import { RemoteData } from '../../core/data/remote-data' ;
@@ -15,7 +15,6 @@ import { getItemPageRoute } from '../item-page-routing-paths';
1515import { AuthorizationDataService } from '../../core/data/feature-authorization/authorization-data.service' ;
1616import { FeatureID } from '../../core/data/feature-authorization/feature-id' ;
1717import { ServerResponseService } from '../../core/services/server-response.service' ;
18- import { SignpostingDataService } from '../../core/data/signposting-data.service' ;
1918import { SignpostingLink } from '../../core/data/signposting-links.model' ;
2019import { isNotEmpty } from '../../shared/empty.util' ;
2120import { LinkDefinition , LinkHeadService } from '../../core/services/link-head.service' ;
@@ -79,7 +78,6 @@ export class ItemPageComponent implements OnInit, OnDestroy {
7978 protected items : ItemDataService ,
8079 protected authorizationService : AuthorizationDataService ,
8180 protected responseService : ServerResponseService ,
82- protected signpostingDataService : SignpostingDataService ,
8381 protected linkHeadService : LinkHeadService ,
8482 @Inject ( PLATFORM_ID ) protected platformId : string
8583 ) {
@@ -111,29 +109,25 @@ export class ItemPageComponent implements OnInit, OnDestroy {
111109 * @private
112110 */
113111 private initPageLinks ( ) : void {
114- this . route . params . subscribe ( params => {
115- this . signpostingDataService . getLinks ( params . id ) . pipe ( take ( 1 ) ) . subscribe ( ( signpostingLinks : SignpostingLink [ ] ) => {
116- let links = '' ;
117- this . signpostingLinks = signpostingLinks ;
118-
119- signpostingLinks . forEach ( ( link : SignpostingLink ) => {
120- links = links + ( isNotEmpty ( links ) ? ', ' : '' ) + `<${ link . href } > ; rel="${ link . rel } "` + ( isNotEmpty ( link . type ) ? ` ; type="${ link . type } " ` : ' ' ) ;
121- let tag : LinkDefinition = {
122- href : link . href ,
123- rel : link . rel
124- } ;
125- if ( isNotEmpty ( link . type ) ) {
126- tag = Object . assign ( tag , {
127- type : link . type
128- } ) ;
129- }
130- this . linkHeadService . addTag ( tag ) ;
131- } ) ;
132-
133- if ( isPlatformServer ( this . platformId ) ) {
134- this . responseService . setHeader ( 'Link' , links ) ;
112+ this . route . data . subscribe ( data => {
113+ this . signpostingLinks = data . links ?? [ ] ;
114+ let links = '' ;
115+ this . signpostingLinks . forEach ( ( link : SignpostingLink ) => {
116+ links = links + ( isNotEmpty ( links ) ? ', ' : '' ) + `<${ link . href } > ; rel="${ link . rel } "` + ( isNotEmpty ( link . type ) ? ` ; type="${ link . type } " ` : ' ' ) ;
117+ let tag : LinkDefinition = {
118+ href : link . href ,
119+ rel : link . rel
120+ } ;
121+ if ( isNotEmpty ( link . type ) ) {
122+ tag = Object . assign ( tag , {
123+ type : link . type
124+ } ) ;
135125 }
126+ this . linkHeadService . addTag ( tag ) ;
136127 } ) ;
128+ if ( isPlatformServer ( this . platformId ) ) {
129+ this . responseService . setHeader ( 'Link' , links ) ;
130+ }
137131 } ) ;
138132 }
139133
0 commit comments