Skip to content

Commit b207e74

Browse files
[DSC-1433] add OpenGraph and Twitter card tags to setDSOMetaTags()
1 parent f6d0639 commit b207e74

1 file changed

Lines changed: 57 additions & 0 deletions

File tree

src/app/core/metadata/metadata.service.ts

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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
/**
@@ -467,6 +474,56 @@ export class MetadataService {
467474
}
468475
}
469476

477+
/**
478+
* Add <meta name="og:title" ... > to the <head>
479+
*/
480+
private setOpenGraphTitleTag(): void {
481+
const value = this.getMetaTagValue('dc.title');
482+
this.addMetaTag('og:title', value);
483+
}
484+
485+
/**
486+
* Add <meta name="og:description" ... > to the <head>
487+
*/
488+
private setOpenGraphDescriptionTag(): void {
489+
// TODO: truncate abstract
490+
const value = this.getMetaTagValue('dc.description.abstract');
491+
this.addMetaTag('og:description', value);
492+
}
493+
494+
/**
495+
* Add <meta name="og:image" ... > to the <head>
496+
*/
497+
private setOpenGraphImageTag(): void {
498+
const value = '';
499+
this.addMetaTag('og:image', value);
500+
}
501+
502+
/**
503+
* Add <meta name="twitter:title" ... > to the <head>
504+
*/
505+
private setTwitterTitleTag(): void {
506+
const value = this.getMetaTagValue('dc.title');
507+
this.addMetaTag('twitter:title', value);
508+
}
509+
510+
/**
511+
* Add <meta name="twitter:description" ... > to the <head>
512+
*/
513+
private setTwitterDescriptionTag(): void {
514+
// TODO: truncate abstract
515+
const value = this.getMetaTagValue('dc.description.abstract');
516+
this.addMetaTag('twitter:description', value);
517+
}
518+
519+
/**
520+
* Add <meta name="twitter:image" ... > to the <head>
521+
*/
522+
private setTwitterImageTag(): void {
523+
const value = '';
524+
this.addMetaTag('twitter:image', value);
525+
}
526+
470527
getBitLinkIfDownloadable(bitstream: Bitstream, bitstreamRd: RemoteData<PaginatedList<Bitstream>>): Observable<string> {
471528
return observableOf(bitstream).pipe(
472529
getDownloadableBitstream(this.authorizationService),

0 commit comments

Comments
 (0)