export type ArrayOrValue = T | T[]; export type Nullable = T | null; export interface Pagination { page: number; limit: number; pages: number; total: number; next: Nullable; prev: Nullable; } export interface Identification { slug: string; id: string; } export interface Metadata { meta_title?: Nullable | undefined; meta_description?: Nullable | undefined; } export interface Excerpt { excerpt?: string | undefined; custom_excerpt?: string | undefined; } export interface CodeInjection { codeinjection_head?: Nullable | undefined; codeinjection_foot?: Nullable | undefined; } /** Metadata for Facebook */ export interface Facebook { og_image?: Nullable | undefined; og_title?: Nullable | undefined; og_description?: Nullable | undefined; } export interface Twitter { twitter_image?: Nullable | undefined; twitter_title?: Nullable | undefined; twitter_description?: Nullable | undefined; } export interface SocialMedia extends Facebook, Twitter { } export interface Settings extends Metadata, CodeInjection, SocialMedia { title?: string | undefined; description?: string | undefined; logo?: string | undefined; icon?: string | undefined; accent_color?: Nullable | undefined; cover_image?: string | undefined; facebook?: string | undefined; twitter?: string | undefined; lang?: string | undefined; timezone?: string | undefined; ghost_head?: Nullable | undefined; ghost_foot?: Nullable | undefined; navigation?: | Array<{ label: string; url: string; }> | undefined; secondary_navigation?: | Array<{ label: string; url: string; }> | undefined; url: string; } export interface Author extends Identification, Metadata { name?: string | undefined; profile_image?: Nullable | undefined; cover_image?: Nullable | undefined; bio?: Nullable | undefined; website?: Nullable | undefined; location?: Nullable | undefined; facebook?: Nullable | undefined; twitter?: Nullable | undefined; url?: Nullable | undefined; count?: { posts: number; } | undefined; } export type TagVisibility = "public" | "internal"; export interface Tag extends Identification, Metadata, SocialMedia { name?: string | undefined; description?: Nullable | undefined; feature_image?: Nullable | undefined; visibility?: TagVisibility | undefined; url?: string | undefined; canonical_url?: Nullable | undefined; accent_color?: Nullable | undefined; count?: { posts: number; } | undefined; } export interface PostOrPage extends Identification, Excerpt, CodeInjection, Metadata, SocialMedia { // Identification uuid?: string | undefined; comment_id?: string | undefined; featured?: boolean | undefined; // Post or Page title?: string | undefined; html?: Nullable | undefined; plaintext?: Nullable | undefined; // Image feature_image?: Nullable | undefined; feature_image_alt?: Nullable | undefined; feature_image_caption?: Nullable | undefined; // Dates created_at?: string | undefined; updated_at?: Nullable | undefined; published_at?: Nullable | undefined; // Custom Template for posts and pages custom_template?: Nullable | undefined; // Post or Page page?: boolean | undefined; // Reading time reading_time?: number | undefined; // Tags - Only shown when using Include param tags?: Tag[] | undefined; primary_tag?: Nullable | undefined; // Authors - Only shown when using Include Param authors?: Author[] | undefined; primary_author?: Nullable | undefined; url?: string | undefined; canonical_url?: Nullable | undefined; } export type GhostData = PostOrPage | Author | Tag | Settings; export type IncludeParam = "authors" | "tags" | "count.posts"; export type FieldParam = string; export type FormatParam = "html" | "plaintext"; export type FilterParam = string; export type LimitParam = number | string; export type PageParam = number; export type OrderParam = string; export interface Params { include?: ArrayOrValue | undefined; fields?: ArrayOrValue | undefined; formats?: ArrayOrValue | undefined; filter?: ArrayOrValue | undefined; limit?: ArrayOrValue | undefined; page?: ArrayOrValue | undefined; order?: ArrayOrValue | undefined; } export interface BrowseFunction { (options?: Params, memberToken?: Nullable): Promise; } export interface ReadFunction { ( data: { id: Nullable } | { slug: Nullable }, options?: Params, memberToken?: Nullable, ): Promise; } interface BrowseResults extends Array { meta: { pagination: Pagination }; } export interface PostsOrPages extends BrowseResults { } export interface Authors extends BrowseResults { } export interface Tags extends BrowseResults { } export interface SettingsResponse extends Settings { meta: any; } export interface GhostError { errors: Array<{ message: string; errorType: string; }>; } export interface GhostContentAPIOptions { url: string; /** * Version of GhostContentAPI * * Supported Versions: 'v2', 'v3', 'v4', 'v5.0', 'canary' */ version: "v2" | "v3" | "v4" | "v5.0" | "canary"; key: string; /** @deprecated since version v2 */ host?: string | undefined; /** @default "ghost" */ ghostPath?: string | undefined; } export interface GhostAPI { posts: { browse: BrowseFunction; read: ReadFunction; }; authors: { browse: BrowseFunction; read: ReadFunction; }; tags: { browse: BrowseFunction; read: ReadFunction; }; pages: { browse: BrowseFunction; read: ReadFunction; }; settings: { browse: BrowseFunction; }; } declare var GhostContentAPI: { (options: GhostContentAPIOptions): GhostAPI; new(options: GhostContentAPIOptions): GhostAPI; }; export default GhostContentAPI;