@spoolcms/nextjs
Version:
The beautiful headless CMS for Next.js developers
148 lines (147 loc) • 4 kB
TypeScript
export interface SpoolConfig {
apiKey?: string;
siteId?: string;
baseUrl?: string;
}
export interface ImageObject {
original: string;
thumb: string;
small: string;
}
interface SpoolContentBase {
id: string;
slug: string;
title: string;
created_at: string;
updated_at: string;
description?: string;
seoTitle?: string;
seoDescription?: string;
ogTitle?: string;
ogDescription?: string;
ogImage?: string | ImageObject;
body?: string;
body_markdown?: string;
author?: string;
excerpt?: string;
tags?: string[];
featured?: boolean;
template?: string;
category?: string;
[key: string]: any;
}
export interface SpoolDraftContent extends SpoolContentBase {
status: 'draft';
published_at?: undefined;
}
export interface SpoolPublishedContent extends SpoolContentBase {
status: 'published';
published_at: string;
}
export type SpoolContent = SpoolPublishedContent;
export type SpoolContentWithDrafts = SpoolDraftContent | SpoolPublishedContent;
export declare function isPublishedContent(content: SpoolContentWithDrafts): content is SpoolPublishedContent;
export declare function isDraftContent(content: SpoolContentWithDrafts): content is SpoolDraftContent;
export interface BlogPost extends SpoolContentBase {
body: string;
body_markdown?: string;
author?: string;
tags?: string[];
featured?: boolean;
excerpt?: string;
}
export interface Page extends SpoolContentBase {
body: string;
body_markdown?: string;
template?: string;
}
export interface PublishedBlogPost extends BlogPost {
status: 'published';
published_at: string;
}
export interface PublishedPage extends Page {
status: 'published';
published_at: string;
}
export interface SpoolContentLegacy {
id: string;
slug: string;
title: string;
data: Record<string, any>;
status: 'draft' | 'published';
created_at: string;
updated_at: string;
published_at?: string;
}
export interface SpoolField {
name: string;
type: 'text' | 'textarea' | 'markdown' | 'number' | 'boolean' | 'date' | 'image' | 'select' | 'multiselect';
label?: string;
required?: boolean;
default?: any;
options?: string[];
validation?: {
min?: number;
max?: number;
pattern?: string;
};
}
export interface SpoolCollectionSchema {
fields: SpoolField[];
}
export interface SpoolCollection {
id: string;
name: string;
slug: string;
schema: SpoolCollectionSchema;
created_at: string;
updated_at?: string;
}
export interface ImageSizes {
original: string;
thumb: string;
small: string;
medium?: string;
large?: string;
}
export type ImageSize = 'thumb' | 'small' | 'medium' | 'large' | 'original';
export interface GetSpoolContentOptions {
collection: string;
slug?: string;
config?: SpoolConfig;
renderHtml?: boolean;
revalidate?: number;
cache?: 'force-cache' | 'no-store' | 'default';
includeDrafts?: boolean;
includeReferences?: boolean;
limit?: number;
offset?: number;
fetchAll?: boolean;
}
export interface GetSpoolStaticParamsOptions {
collection: string;
config?: SpoolConfig;
}
export interface GenerateSpoolSitemapOptions {
collections: string[];
staticPages?: {
url: string;
priority?: number;
changeFrequency?: 'always' | 'hourly' | 'daily' | 'weekly' | 'monthly' | 'yearly' | 'never';
}[];
config?: SpoolConfig;
}
export type SpoolContentArray<T = SpoolContent> = T[];
export type SpoolContentSingle<T = SpoolContent> = T | null;
export type CollectionContent<T extends string> = T extends 'blog' ? BlogPost : T extends 'pages' ? Page : SpoolContent;
export interface SpoolRedirect {
id: string;
source: string;
destination: string;
created_at: string;
updated_at?: string;
}
export interface GetSpoolRedirectsOptions {
config?: SpoolConfig;
}
export {};