@@ -16,6 +16,7 @@ import { ButtonModule } from "primeng/button";
1616import { InputSwitchModule } from "primeng/inputswitch" ;
1717
1818import { SanitizerHtmlPipe } from "../../pipes/sanitizer-html.pipe" ;
19+ import { SearchDialogComponent } from "../../partials/search-dialog/search-dialog.component" ;
1920
2021@Component ( {
2122 selector : 'app-post-details' ,
@@ -31,41 +32,39 @@ import { SanitizerHtmlPipe } from "../../pipes/sanitizer-html.pipe";
3132 ToolbarModule ,
3233 ButtonModule ,
3334 InputSwitchModule ,
34- SanitizerHtmlPipe
35+ SanitizerHtmlPipe ,
36+ SearchDialogComponent
3537 ] ,
3638 templateUrl : './post-details.component.html' ,
3739 styleUrl : './post-details.component.scss'
3840} )
39- export class PostDetailsComponent implements OnInit , OnDestroy {
41+ export class PostDetailsComponent implements OnInit {
4042 post$ ! : Observable < Post > ;
4143 blogInfo ! : BlogInfo ;
44+ blogId : string = "" ;
4245 blogName : string = "" ;
43- blogSocialLinks ! : BlogLinks ;
44- checked : boolean = true ;
45- selectedTheme : string = "dark" ;
46- route : ActivatedRoute = inject ( ActivatedRoute ) ;
47- private blogService : BlogService = inject ( BlogService ) ;
46+ checked : boolean = true ;
47+ selectedTheme : string = "dark" ;
4848 themeService : ThemeService = inject ( ThemeService ) ;
49- private querySubscription ?: Subscription ;
49+ private blogService : BlogService = inject ( BlogService ) ;
5050
51- @Input ( { required : true } ) slug ! : string ;
51+ @Input ( { required : true } )
52+ set slug ( slug : string ) {
53+ this . post$ = this . blogService . getSinglePost ( slug ) ;
54+ }
5255
5356 ngOnInit ( ) : void {
54- this . querySubscription = this . blogService
55- . getBlogInfo ( )
56- . subscribe ( ( data ) => {
57- this . blogInfo = data ;
58- this . blogName = this . blogInfo . title ;
59- } ) ;
60- this . post$ = this . blogService . getSinglePost ( this . slug ) ;
57+ this . blogService
58+ . getBlogInfo ( )
59+ . subscribe ( ( data ) => {
60+ this . blogInfo = data ;
61+ this . blogId = this . blogInfo . id ;
62+ this . blogName = this . blogInfo . title ;
63+ } ) ;
6164 }
6265
6366 onThemeChange ( theme : string ) : void {
64- this . selectedTheme = theme ;
65- this . themeService . setTheme ( theme ) ;
66- }
67-
68- ngOnDestroy ( ) : void {
69- this . querySubscription ?. unsubscribe ( ) ;
67+ this . selectedTheme = theme ;
68+ this . themeService . setTheme ( theme ) ;
7069 }
7170}
0 commit comments