Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: author and co-authors to be clickable links leading to the author's page on Hashnode #72

Closed
Show file tree
Hide file tree
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 @@ -7,13 +7,19 @@ <h1 class="title">{{ post.title }}</h1>
<div class="author-info">
@if (isTeam) {
<p-avatarGroup styleClass="mb-3" >
<p-avatar [image]="post.author.profilePicture" size="large" shape="circle" title="{{ post.author.name}}"></p-avatar>
<a href="https://hashnode.com/@{{post.author.name | removeSpecialChars}}" target="_blank">
<p-avatar [image]="post.author.profilePicture" size="large" shape="circle" title="{{post.author.name}}"></p-avatar>
</a>
@for (coAuthor of post.coAuthors; track coAuthor.username) {
<p-avatar [image]="coAuthor.profilePicture" size="large" shape="circle" title="{{ coAuthor.username}}"></p-avatar>
<a href="https://hashnode.com/@{{coAuthor.username | removeSpecialChars }}" target="_blank">
<p-avatar [image]="coAuthor.profilePicture" size="large" shape="circle" title="{{coAuthor.username}}"></p-avatar>
</a>
}
</p-avatarGroup>
} @else {
<p-avatar [image]="post.author.profilePicture" size="large" shape="circle" title="{{ post.author.name}}"></p-avatar>
<a href='https://hashnode.com/@{{post.author.name | removeSpecialChars}}' target="_blank">
<p-avatar [image]="post.author.profilePicture" size="large" shape="circle" title="{{post.author.name}}"></p-avatar>
</a>
}
<div class="author-text">
<span class="author-name">{{post.author.name}} {{isTeam && post.coAuthors.length > 0 ? 'with ' + post.coAuthors.length + ' co-author' + (post.coAuthors.length > 1 ? 's' : '') : ''}}</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { ButtonModule } from "primeng/button";
import { InputSwitchModule } from "primeng/inputswitch";
import { AvatarModule } from 'primeng/avatar';
import { AvatarGroupModule } from 'primeng/avatargroup';
import { RemoveSpecialCharsPipe } from "../../pipes/special-characters-remover.pipe";

@Component({
selector: "app-post-details",
Expand All @@ -40,6 +41,7 @@ import { AvatarGroupModule } from 'primeng/avatargroup';
SearchDialogComponent,
AvatarGroupModule,
AvatarModule,
RemoveSpecialCharsPipe
],
templateUrl: "./post-details.component.html",
styleUrl: "./post-details.component.scss",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { RemoveSpecialCharsPipe } from "./special-characters-remover.pipe"

describe("RemoveSpecialCharsPipe ",()=>{
const pipe = new RemoveSpecialCharsPipe ()

it('should transform and return a string with no curly brackets and no spaces',()=>{
expect(pipe.transform('{{name}} ')).toBe('name');
})
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Pipe, PipeTransform } from "@angular/core";

@Pipe({
name: 'removeSpecialChars',
standalone: true
})

export class RemoveSpecialCharsPipe implements PipeTransform{
transform(value: string) : string {
return value.replace(/[{()}]/g, "").trim();
}

}