@@ -206,6 +206,13 @@ export class MetadataService {
206206 this . setCitationTechnicalReportNumberTag ( ) ;
207207 }
208208
209+ this . setOpenGraphTitleTag ( ) ;
210+ this . setOpenGraphDescriptionTag ( ) ;
211+ this . setOpenGraphImageTag ( ) ;
212+
213+ this . setTwitterTitleTag ( ) ;
214+ this . setTwitterDescriptionTag ( ) ;
215+ this . setTwitterImageTag ( ) ;
209216 }
210217
211218 /**
@@ -401,22 +408,75 @@ export class MetadataService {
401408 * Add <meta name="citation_pdf_url" ... > to the <head>
402409 */
403410 private setCitationPdfUrlTag ( ) : void {
411+ this . setPrimaryBitstreamInBundleTag ( 'ORIGINAL' , 'citation_pdf_url' ) ;
412+ }
413+
414+ /**
415+ * Add <meta name="og:title" ... > to the <head>
416+ */
417+ private setOpenGraphTitleTag ( ) : void {
418+ const value = this . getMetaTagValue ( 'dc.title' ) ;
419+ this . addMetaTag ( 'og:title' , value ) ;
420+ }
421+
422+ /**
423+ * Add <meta name="og:description" ... > to the <head>
424+ */
425+ private setOpenGraphDescriptionTag ( ) : void {
426+ // TODO: truncate abstract
427+ const value = this . getMetaTagValue ( 'dc.description.abstract' ) ;
428+ this . addMetaTag ( 'og:description' , value ) ;
429+ }
430+
431+ /**
432+ * Add <meta name="og:image" ... > to the <head>
433+ */
434+ private setOpenGraphImageTag ( ) : void {
435+ this . setPrimaryBitstreamInBundleTag ( 'THUMBNAIL' , 'og:image' ) ;
436+ }
437+
438+
439+ /**
440+ * Add <meta name="twitter:title" ... > to the <head>
441+ */
442+ private setTwitterTitleTag ( ) : void {
443+ const value = this . getMetaTagValue ( 'dc.title' ) ;
444+ this . addMetaTag ( 'twitter:title' , value ) ;
445+ }
446+
447+ /**
448+ * Add <meta name="twitter:description" ... > to the <head>
449+ */
450+ private setTwitterDescriptionTag ( ) : void {
451+ // TODO: truncate abstract
452+ const value = this . getMetaTagValue ( 'dc.description.abstract' ) ;
453+ this . addMetaTag ( 'twitter:description' , value ) ;
454+ }
455+
456+ /**
457+ * Add <meta name="twitter:image" ... > to the <head>
458+ */
459+ private setTwitterImageTag ( ) : void {
460+ this . setPrimaryBitstreamInBundleTag ( 'THUMBNAIL' , 'twitter:image' ) ;
461+ }
462+
463+ private setPrimaryBitstreamInBundleTag ( bundleName : string , tag : string ) : void {
404464 if ( this . currentObject . value instanceof Item ) {
405465 const item = this . currentObject . value as Item ;
406466
407- // Retrieve the ORIGINAL bundle for the item
467+ // Retrieve the bundle for the item
408468 this . bundleDataService . findByItemAndName (
409469 item ,
410- 'ORIGINAL' ,
470+ bundleName ,
411471 true ,
412472 true ,
413473 followLink ( 'primaryBitstream' ) ,
414474 followLink ( 'bitstreams' , {
415- findListOptions : {
416- // limit the number of bitstreams used to find the citation pdf url to the number
417- // shown by default on an item page
418- elementsPerPage : this . appConfig . item . bitstream . pageSize
419- }
475+ findListOptions : {
476+ // limit the number of bitstreams used to find the citation pdf url to the number
477+ // shown by default on an item page
478+ elementsPerPage : this . appConfig . item . bitstream . pageSize
479+ }
420480 } , followLink ( 'format' ) ) ,
421481 ) . pipe (
422482 getFirstSucceededRemoteDataPayload ( ) ,
@@ -460,7 +520,7 @@ export class MetadataService {
460520 ) . subscribe ( ( link : string ) => {
461521 // Use the found link to set the <meta> tag
462522 this . addMetaTag (
463- 'citation_pdf_url' ,
523+ tag ,
464524 new URLCombiner ( this . hardRedirectService . getCurrentOrigin ( ) , link ) . toString ( )
465525 ) ;
466526 } ) ;
0 commit comments