feat(ghost): Implement Tag, Author and Page models; add advanced filtering, search, bulk operations, image upload, related-posts, update tests and bump dependencies
This commit is contained in:
50
ts/classes.author.ts
Normal file
50
ts/classes.author.ts
Normal file
@@ -0,0 +1,50 @@
|
||||
import type { Ghost } from './classes.ghost.js';
|
||||
import type { IAuthor } from './classes.post.js';
|
||||
|
||||
export class Author {
|
||||
public ghostInstanceRef: Ghost;
|
||||
public authorData: IAuthor;
|
||||
|
||||
constructor(ghostInstanceRefArg: Ghost, authorData: IAuthor) {
|
||||
this.ghostInstanceRef = ghostInstanceRefArg;
|
||||
this.authorData = authorData;
|
||||
}
|
||||
|
||||
public getId(): string {
|
||||
return this.authorData.id;
|
||||
}
|
||||
|
||||
public getName(): string {
|
||||
return this.authorData.name;
|
||||
}
|
||||
|
||||
public getSlug(): string {
|
||||
return this.authorData.slug;
|
||||
}
|
||||
|
||||
public getProfileImage(): string | undefined {
|
||||
return this.authorData.profile_image;
|
||||
}
|
||||
|
||||
public getBio(): string | undefined {
|
||||
return this.authorData.bio;
|
||||
}
|
||||
|
||||
public toJson(): IAuthor {
|
||||
return this.authorData;
|
||||
}
|
||||
|
||||
public async update(authorData: Partial<IAuthor>): Promise<Author> {
|
||||
try {
|
||||
const updatedAuthorData = await this.ghostInstanceRef.adminApi.users.edit({
|
||||
...authorData,
|
||||
id: this.getId()
|
||||
});
|
||||
this.authorData = updatedAuthorData;
|
||||
return this;
|
||||
} catch (error) {
|
||||
console.error('Error updating author:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user