UNPKG

@ai-growth/nextjs

Version:

Seamlessly integrate Sanity CMS with Next.js applications for automated blog routing and rendering

167 lines 4.21 kB
import React, { ReactNode, ComponentType } from 'react'; import type { CmsContent } from '../types'; /** * Props interface for template components */ export interface TemplateProps { content: CmsContent | null; className?: string; showMetadata?: boolean; showAuthor?: boolean; customRenderers?: ContentRenderers; isLoading?: boolean; error?: string; onRetry?: () => void; } /** * Custom content renderers for specific sections */ export interface ContentRenderers { header?: (content: CmsContent) => ReactNode; body?: (content: any) => ReactNode; author?: (author: any) => ReactNode; metadata?: (metadata: any) => ReactNode; footer?: (content: CmsContent) => ReactNode; } /** * Template component type */ export type TemplateComponent = ComponentType<TemplateProps>; /** * Template registry mapping content types to components */ export interface TemplateRegistry { [contentType: string]: TemplateComponent; } /** * Theme configuration for design tokens */ export interface CmsTheme { colors?: { primary?: string; secondary?: string; background?: string; surface?: string; text?: string; textSecondary?: string; accent?: string; success?: string; warning?: string; error?: string; border?: string; }; typography?: { fontFamily?: string; fontFamilyMono?: string; fontSize?: { xs?: string; sm?: string; base?: string; lg?: string; xl?: string; '2xl'?: string; '3xl'?: string; '4xl'?: string; }; fontWeight?: { normal?: string; medium?: string; semibold?: string; bold?: string; }; lineHeight?: { tight?: string; normal?: string; relaxed?: string; }; }; spacing?: { xs?: string; sm?: string; md?: string; lg?: string; xl?: string; '2xl'?: string; '3xl'?: string; '4xl'?: string; }; borderRadius?: { none?: string; sm?: string; md?: string; lg?: string; xl?: string; full?: string; }; shadows?: { sm?: string; md?: string; lg?: string; xl?: string; }; breakpoints?: { sm?: string; md?: string; lg?: string; xl?: string; }; } /** * CMS configuration options */ export interface CmsConfig { templates?: TemplateRegistry; theme?: CmsTheme; defaultContentType?: string; enableThemeProvider?: boolean; customRenderers?: ContentRenderers; } /** * CMS context value */ export interface CmsContextValue { config: CmsConfig; getTemplate: (contentType: string) => TemplateComponent; getTheme: () => CmsTheme; getCustomRenderers: () => ContentRenderers | undefined; isTemplateRegistered: (contentType: string) => boolean; registerTemplate: (contentType: string, component: TemplateComponent) => void; updateTheme: (themeUpdate: Partial<CmsTheme>) => void; } /** * Default theme configuration */ export declare const defaultTheme: CmsTheme; /** * CmsProvider Props */ export interface CmsProviderProps { children: ReactNode; config?: CmsConfig; } /** * CmsProvider - provides CMS configuration and template management */ export declare const CmsProvider: React.FC<CmsProviderProps>; /** * Hook to access CMS context */ export declare const useCms: () => CmsContextValue; /** * Hook to access theme configuration */ export declare const useCmsTheme: () => CmsTheme; /** * Hook to access template resolution */ export declare const useCmsTemplate: (contentType: string) => TemplateComponent | null; /** * Create CSS custom properties from theme */ export declare const createCssCustomProperties: (theme: CmsTheme) => Record<string, string>; /** * Merge multiple theme configurations */ export declare const mergeThemes: (...themes: Partial<CmsTheme>[]) => CmsTheme; export default CmsProvider; //# sourceMappingURL=CmsProvider.d.ts.map