From 3c922d1cf54d013583d0414ebf80c90ccefe448f Mon Sep 17 00:00:00 2001 From: guams Date: Wed, 18 Jun 2025 18:37:02 +0200 Subject: [PATCH] image embed with og protocol updated --- src/app/pages/post/post.component.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/app/pages/post/post.component.ts b/src/app/pages/post/post.component.ts index 97882f4..8de5476 100644 --- a/src/app/pages/post/post.component.ts +++ b/src/app/pages/post/post.component.ts @@ -17,6 +17,7 @@ import {Button} from 'primeng/button'; import {DialogModule} from 'primeng/dialog'; import {AuthService} from '../../auth.service'; import {Role} from '../../models/role'; +import {Meta} from '@angular/platform-browser'; @Component({ selector: 'app-post', @@ -46,7 +47,8 @@ export class PostComponent { private postService: PostService, private commentService: CommentService, private messageService: MessageService, - private authService: AuthService,) { + private authService: AuthService, + private meta: Meta) { this.route.paramMap.subscribe(params => { if (!(this.authService.isSessionExpired()) && this.authService.isAuthenticated()) { const authenticatedAuthor = this.authService.getAuthenticatedAuthor(); @@ -71,6 +73,9 @@ export class PostComponent { this.comments = res.comment this.sortCommentList() this.comments.forEach(comment => this.commentDeleteDialogMap.set(comment.id, false)); + this.meta.updateTag({property: 'og:title', content: res.post.title}); + this.meta.updateTag({property: 'og:description', content: this.cutDesc(res.post.description)}); + this.meta.updateTag({property: 'og:image', content: `data:image/jpeg;base64,${res.post.illustration}`}); }, error: err => this.failureMessage("Erreur", err.error.message) })); @@ -81,6 +86,14 @@ export class PostComponent { }); } + cutDesc(desc: string): string { + let output: string = ''; + for (let i = 0; i < 256; i++) { + output += desc[i]; + } + return output; + } + addNewCommentToList(comment: Comment) { this.comments.push(comment); console.log(this.comments)