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:
2025-10-07 13:53:58 +00:00
parent a0ffc7c4d7
commit a687b639d2
14 changed files with 7054 additions and 2367 deletions

65
ts/classes.page.ts Normal file
View File

@@ -0,0 +1,65 @@
import type { Ghost } from './classes.ghost.js';
import type { IPost, IAuthor } from './classes.post.js';
export interface IPage extends IPost {}
export class Page {
public ghostInstanceRef: Ghost;
public pageData: IPage;
constructor(ghostInstanceRefArg: Ghost, pageData: IPage) {
this.ghostInstanceRef = ghostInstanceRefArg;
this.pageData = pageData;
}
public getId(): string {
return this.pageData.id;
}
public getTitle(): string {
return this.pageData.title;
}
public getHtml(): string {
return this.pageData.html;
}
public getSlug(): string {
return this.pageData.slug;
}
public getFeatureImage(): string | undefined {
return this.pageData.feature_image;
}
public getAuthor(): IAuthor {
return this.pageData.primary_author;
}
public toJson(): IPage {
return this.pageData;
}
public async update(pageData: Partial<IPage>): Promise<Page> {
try {
const updatedPageData = await this.ghostInstanceRef.adminApi.pages.edit({
...pageData,
id: this.getId()
});
this.pageData = updatedPageData;
return this;
} catch (error) {
console.error('Error updating page:', error);
throw error;
}
}
public async delete(): Promise<void> {
try {
await this.ghostInstanceRef.adminApi.pages.delete({ id: this.getId() });
} catch (error) {
console.error(`Error deleting page with id ${this.getId()}:`, error);
throw error;
}
}
}