Skip to content

Instantly share code, notes, and snippets.

@nicolaisueper
Last active October 15, 2019 11:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nicolaisueper/7776accc08d00e0e03967dd1a565eadd to your computer and use it in GitHub Desktop.
Save nicolaisueper/7776accc08d00e0e03967dd1a565eadd to your computer and use it in GitHub Desktop.
Ghost ContentAPI type definitions
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>;
}
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;
}
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;
}
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;
}
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