Skip to content

Commit 1641548

Browse files
Merge pull request #60 from DongreJaipal/my-fix-branch
feat(component): add new feature If it is a team blog,then display group of author profile images.
2 parents feeba84 + ded6bbe commit 1641548

File tree

4 files changed

+27
-2
lines changed

4 files changed

+27
-2
lines changed

angular-primeng-app/src/app/components/post-details/post-details.component.html

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,18 @@ <h1 class="title">{{ post.title }}</h1>
55
<img class="cover-image" [src]="post.coverImage.url" alt="Cover image for {{ post.title }}">
66
<div class="post-details">
77
<div class="author-info">
8-
<img class="author-image" [src]="post.author.profilePicture" alt="{{ post.author.name}}">
8+
@if (isTeam) {
9+
<p-avatarGroup styleClass="mb-3" >
10+
<p-avatar [image]="post.author.profilePicture" size="large" shape="circle" title="{{ post.author.name}}"></p-avatar>
11+
@for (coAuthor of post.coAuthors; track coAuthor.username) {
12+
<p-avatar [image]="coAuthor.profilePicture" size="large" shape="circle" title="{{ coAuthor.username}}"></p-avatar>
13+
}
14+
</p-avatarGroup>
15+
} @else {
16+
<p-avatar [image]="coAuthor.profilePicture" size="large" shape="circle" title="{{ coAuthor.username}}"></p-avatar>
17+
}
918
<div class="author-text">
10-
<span class="author-name">{{post.author.name}}</span>
19+
<span class="author-name">{{post.author.name}} {{isTeam && post.coAuthors.length > 0 ? 'with ' +post.coAuthors.length + ' co-author' + (post.coAuthors.length > 1 ? 's' : '') : ''}}</span>
1120
<div class="post-meta">
1221
<p-tag value="{{post.publishedAt | date: 'MMM dd, yyyy' }}"><i
1322
class="tag-icon pi pi-calendar"></i></p-tag>

angular-primeng-app/src/app/components/post-details/post-details.component.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ import { InputSwitchModule } from "primeng/inputswitch";
1818
import { SanitizerHtmlPipe } from "../../pipes/sanitizer-html.pipe";
1919
import { YoutubeVideoEmbedDirective } from "../../directives/youtube-video-embed.directive";
2020
import { ViewportScroller } from "@angular/common";
21+
import { AvatarModule } from 'primeng/avatar';
22+
import { AvatarGroupModule } from 'primeng/avatargroup';
2123

2224
@Component({
2325
selector: "app-post-details",
@@ -36,12 +38,15 @@ import { ViewportScroller } from "@angular/common";
3638
ButtonModule,
3739
InputSwitchModule,
3840
SearchDialogComponent,
41+
AvatarGroupModule,
42+
AvatarModule,
3943
],
4044
templateUrl: "./post-details.component.html",
4145
styleUrl: "./post-details.component.scss",
4246
})
4347
export class PostDetailsComponent implements OnInit, OnDestroy {
4448
checked: boolean = true;
49+
isTeam: boolean = false;
4550
selectedTheme: string = "dark";
4651
blogURL!: string;
4752
blogInfo!: BlogInfo;
@@ -68,6 +73,7 @@ export class PostDetailsComponent implements OnInit, OnDestroy {
6873
this.blogName = this.blogInfo.title;
6974
const { __typename, ...links } = data.links;
7075
this.blogSocialLinks = links;
76+
this.isTeam = this.blogInfo.isTeam ? true : false;
7177
});
7278
this.post$ = this.blogService.getSinglePost(this.blogURL, this.postSlug);
7379
this.querySubscription = this.blogService

angular-primeng-app/src/app/graphql.operations.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,10 @@ export const GET_SINGLE_POST = gql`
139139
name
140140
profilePicture
141141
}
142+
coAuthors {
143+
username
144+
profilePicture
145+
}
142146
coverImage {
143147
url
144148
}

angular-primeng-app/src/app/models/post.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export type Post = {
55
readTimeInMinutes: number;
66
tags: Tag[];
77
author: Author;
8+
coAuthors: coAuthor[];
89
coverImage: CoverImage;
910
content: Content;
1011
publishedAt: string;
@@ -28,6 +29,11 @@ export interface Author {
2829
socialMediaLinks: SocialMediaLinks;
2930
}
3031

32+
export interface coAuthor {
33+
username: string;
34+
profilePicture: string;
35+
}
36+
3137
export interface SocialMediaLinks {
3238
facebook: string;
3339
github: string;

0 commit comments

Comments
 (0)