Last active
October 15, 2019 11:29
-
-
Save nicolaisueper/7776accc08d00e0e03967dd1a565eadd to your computer and use it in GitHub Desktop.
Ghost ContentAPI type definitions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Post } from "./Post"; | |
import { Author } from "./Author"; | |
import { Tag } from "./Tag"; | |
import { Page } from "./Page"; | |
import { Settings } from "./Settings"; | |
interface ReadParams { | |
slug?: string; | |
id?: string; | |
} | |
interface BaseOptions { | |
include?: string; | |
fields?: string[]; | |
} | |
interface BrowseOptions<T> extends BaseOptions { | |
filter: { [prop in keyof T]: string }; | |
order: { [prop in keyof T]: "ASC" | "DESC" }; | |
limit?: number | "all"; | |
page?: number; | |
} | |
interface FormatOptions { | |
formats?: string[]; | |
} | |
interface Browseable<T, O = {}> { | |
browse: (options?: BrowseOptions<T> & O) => Promise<T>; | |
} | |
interface Readable<T, O = {}> { | |
read: (params?: ReadParams, options?: O) => Promise<T>; | |
} | |
export interface ContentAPI { | |
posts: Readable<Post, FormatOptions> & Browseable<Post>; | |
authors: Readable<Author> & Browseable<Author>; | |
tags: Readable<Tag> & Browseable<Tag>; | |
pages: Readable<Page, FormatOptions> & Browseable<Page>; | |
settings: Browseable<Settings, undefined>; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Tag } from "./Tag"; | |
import { Author } from "./Author"; | |
export interface Page { | |
slug: string; | |
id: string; | |
uuid: string; | |
title: string; | |
html: string; | |
comment_id: string; | |
feature_image: string; | |
featured: boolean; | |
meta_title?: string; | |
meta_description?: string; | |
created_at: string; | |
updated_at: string; | |
published_at: string; | |
custom_excerpt: string; | |
codeinjection_head?: string; | |
codeinjection_foot?: string; | |
og_image?: string; | |
og_title?: string; | |
og_description?: string; | |
twitter_image?: string; | |
twitter_title?: string; | |
twitter_description?: string; | |
custom_template?: string; | |
canonical_url?: string; | |
page: boolean; | |
tags: Tag[]; | |
authors: Author[]; | |
primary_author: Author; | |
primary_tag: Tag[]; | |
url: string; | |
excerpt: string; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Tag } from "./Tag"; | |
import { Author } from "./Author"; | |
export interface Post { | |
slug: string; | |
id: string; | |
uuid: string; | |
title: string; | |
html: string; | |
comment_id: string; | |
feature_image: string; | |
featured: boolean; | |
meta_title?: string; | |
meta_description?: string; | |
created_at: string; | |
updated_at: string; | |
published_at: string; | |
custom_excerpt: string; | |
codeinjection_head?: string; | |
codeinjection_foot?: string; | |
og_image?: string; | |
og_title?: string; | |
og_description?: string; | |
twitter_image?: string; | |
twitter_title?: string; | |
twitter_description?: string; | |
custom_template?: string; | |
canonical_url?: string; | |
page: boolean; | |
tags?: Tag[]; | |
authors?: Author[]; | |
primary_author?: Author; | |
primary_tag?: Tag; | |
url: string; | |
excerpt: string; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export interface Settings { | |
title: string; | |
description: string; | |
logo: string; | |
icon: string; | |
cover_image: string; | |
facebook: string; | |
twitter: string; | |
lang: string; | |
timezone: string; | |
navigation: { label: string; url: string }[]; | |
meta_title?: string; | |
meta_description?: string; | |
og_image?: string; | |
og_title?: string; | |
og_description?: string; | |
twitter_image?: string; | |
twitter_title?: string; | |
twitter_description?: string; | |
url: string; | |
codeinjection_head?: string; | |
codeinjection_foot?: string; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export interface Tag { | |
slug: string; | |
id: string; | |
name: string; | |
description?: string; | |
feature_image?: string; | |
visibility: string; | |
meta_title?: string; | |
meta_description?: string; | |
url: string; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment