-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypes.ts
99 lines (88 loc) · 2.57 KB
/
types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
import { Mobiledoc } from "@bustle/mobiledoc-vdom-renderer";
import { PostOrPage } from "@tryghost/content-api";
import { NextPage } from "next";
import { AppProps } from "next/app";
import { PropsWithChildren, ReactElement, ReactNode } from "react";
// TODO: Replate with Layouts RFC once it's out...
// eslint-disable-next-line @typescript-eslint/ban-types
export type NextPageWithLayout<P = {}, IP = P> = NextPage<P, IP> & {
// eslint-disable-next-line no-unused-vars
getLayout?: (page: ReactElement) => ReactNode;
};
type CamelizeString<T extends PropertyKey> = T extends string
? string extends T
? string
: T extends `${infer F}_${infer R}`
? `${F}${Capitalize<CamelizeString<R>>}`
: T
: T;
type Camelize<T> = { [K in keyof T as CamelizeString<K>]: T[K] };
export type AppPropsWithLayout = AppProps & {
Component: NextPageWithLayout;
};
export interface NowPlayingResponse extends Track {
isPlaying: boolean;
}
export interface TopTracksResponse {
tracks: Track[];
}
export interface Track {
artist: string;
songUrl: string;
title: string;
albumImageUrl: string;
blurAlbumImageUrl: string;
}
export type BaseProps = PropsWithChildren & { className?: string };
export interface RawPostMatter {
slug: string;
content: string;
data: Partial<Post>;
}
export interface Post {
slug: string;
title: string;
status: "published" | "unpublished" | "unlisted";
tags: string[];
postLayout:
| "feature-image"
| "large-feature-image"
| "dark-large-feature-image";
excerpt: string;
singleLiner?: string;
body: string; // Mobiledoc
featured?: boolean;
featureImage?: string;
featureImageFit?: string;
featureImagePosition?: string;
featureImageBlur?: string;
createdAt: string; // has to be a string or getStaticProps screams at you.
}
export type AdminPostOrPage = PostOrPage & {
uuid: string;
mobiledoc: string;
visibility: "public" | "members" | "none";
status: "published" | "draft" | "scheduled" | "sent";
};
export interface GhostPost
extends Camelize<Omit<AdminPostOrPage, "mobiledoc">> {
mobiledoc: Mobiledoc;
plaintext: string | null;
postLayout:
| "feature-image"
| "large-feature-image"
| "dark-large-feature-image";
singleLiner?: string;
featureImageFit?: string;
featureImagePosition?: string;
featureImageBlur?: string;
noIndex?: boolean;
}
// eslint-disable-next-line no-unused-vars
export type MobiledocGetter = (props: {
// eslint-disable-next-line no-unused-vars, @typescript-eslint/ban-ts-comment
// @ts-ignore
// eslint-disable-next-line no-unused-vars, @typescript-eslint/no-explicit-any
payload: any;
key: string;
}) => React.ReactNode;