@spoolcms/nextjs
Version:
The beautiful headless CMS for Next.js developers
63 lines (62 loc) • 2.46 kB
TypeScript
import { SpoolConfig, GetSpoolContentOptions, GetSpoolStaticParamsOptions, GenerateSpoolSitemapOptions, SpoolContent } from '../types';
export interface ContentOptions {
renderHtml?: boolean;
revalidate?: number;
cache?: 'force-cache' | 'no-store' | 'default';
}
export declare class SpoolError extends Error {
code: 'NETWORK_ERROR' | 'AUTH_ERROR' | 'NOT_FOUND' | 'RATE_LIMITED' | 'SERVER_ERROR';
status?: number | undefined;
retryable: boolean;
constructor(message: string, code: 'NETWORK_ERROR' | 'AUTH_ERROR' | 'NOT_FOUND' | 'RATE_LIMITED' | 'SERVER_ERROR', status?: number | undefined, retryable?: boolean);
}
/**
* Flatten content item structure to provide unified field access
* Merges data fields with top-level fields, with data fields taking precedence
* Creates smart markdown field objects for better developer experience
*/
declare function flattenContentItem(item: any): any;
export declare const __testing__: {
clearCache: () => void;
disableCache: boolean;
flattenContentItem: typeof flattenContentItem;
};
/**
* Main function to get content from Spool CMS
* Works seamlessly in both server and client components
*
* Supports both old and new API:
* - getSpoolContent(config, 'blog') // Old way
* - getSpoolContent({ collection: 'blog' }) // New simplified way
*/
export declare function getSpoolContent<T = SpoolContent>(options: GetSpoolContentOptions): Promise<T>;
/**
* Generate static params for Next.js generateStaticParams - ONE LINE HELPER
* Supports both old and new API
*/
export declare function getSpoolStaticParams(options: GetSpoolStaticParamsOptions): Promise<{
slug: string;
}[]>;
/**
* Generate sitemap for Next.js sitemap.ts - ONE LINE HELPER
* Supports both old and new API
*/
export declare function generateSpoolSitemap(options: GenerateSpoolSitemapOptions): Promise<any[]>;
/**
* Helper function to get all collections from Spool CMS
* Supports both old and new API
*/
export declare function getSpoolCollections(config?: SpoolConfig): Promise<any>;
export {};
/**
* Get root-level JSON-LD configuration for a collection and build the JSON-LD object.
* Use this in collection index pages like /blog.
*/
/**
* Generate metadata for Next.js App Router - SIMPLIFIED VERSION
* Auto-detects site URL, path, and everything else from Next.js context
*/
/**
* Legacy version for backward compatibility
* @deprecated Use generateSpoolMetadata(content) instead
*/