Skip to content
This repository has been archived by the owner on Jun 29, 2024. It is now read-only.

Feature: add dynamic og:title & og:description for individual blog posts #113

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { BlogService } from '../../services/blog.service';
import { AsyncPipe, DatePipe } from '@angular/common';
import { SanitizerHtmlPipe } from '../../pipes/sanitizer-html.pipe';
import { Post } from '../../models/post';
import { Observable, Subscription } from 'rxjs';
import {Observable, Subscription, tap} from 'rxjs';
import { ClipboardCopyButtonDirective } from '../../directives/clipboard-copy-button.directive';
import { ThemeService } from '../../services/theme.service';
import { BlogInfo } from '../../models/blog-info';
Expand Down Expand Up @@ -44,10 +44,12 @@ export class PostDetailsComponent implements OnInit, OnDestroy {
this.blogInfo = data;
this.blogName = this.blogInfo.title;
});
this.post$ = this.blogService.getSinglePost(this.blogURL, this.postSlug);

this.meta.updateTag({ name: 'description', content: 'This is a blog post' });
this.meta.updateTag({ name: 'image', content: '/assets/anguhashblog-logo-purple-bgr.jpg' });
this.post$ = this.blogService.getSinglePost(this.blogURL, this.postSlug).pipe(
tap((post:Post)=>{
this.meta.updateTag({ name: 'description', content: post.title });
this.meta.updateTag({ name: 'image', content: post.coverImage.url });
})
);
}

toggleTheme(): void {
Expand Down