image embed with og protocol updated

This commit is contained in:
guams 2025-06-18 18:37:02 +02:00
parent 45d1abccfe
commit 3c922d1cf5

View File

@ -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)