@ai-growth/nextjs
Version:
Seamlessly integrate Sanity CMS with Next.js applications for automated blog routing and rendering
51 lines • 1.87 kB
TypeScript
import React from 'react';
import type { DefaultTemplateProps, CmsContent } from '../types';
export interface CmsRouteHandlerProps {
/** Route parameters from Next.js (for compatibility) */
params?: Promise<{
slug?: string[];
}>;
/** Child components to render for non-CMS routes */
children?: React.ReactNode;
/** Custom template component */
customTemplate?: React.ComponentType<DefaultTemplateProps>;
/** Custom loading component */
loadingComponent?: React.ReactNode;
/** Custom error component */
errorComponent?: React.ComponentType<{
error: string;
onRetry: () => void;
}>;
/** Content validation options */
contentOptions?: Record<string, any>;
/** Additional CSS class names */
className?: string;
/** Whether to show loading state */
showLoading?: boolean;
/** Whether to show error state */
showErrors?: boolean;
/** Callback when route changes */
onRouteChange?: (path: string, isCmsRoute: boolean) => void;
/** Callback when content is loaded */
onContentLoaded?: (content: CmsContent) => void;
/** Callback when content error occurs */
onContentError?: (error: string) => void;
}
export interface CmsRouteState {
isCmsRoute: boolean;
isLoading: boolean;
currentSlug: string;
content: CmsContent | null;
error: string | null;
}
/**
* CMS Route Handler for Next.js App Router
*
* This component handles CMS routing by checking if the current route is a CMS route,
* fetching content accordingly, and rendering the appropriate template or children.
*/
export declare const CmsRouteHandler: React.FC<CmsRouteHandlerProps>;
export declare const useCmsRouteState: () => CmsRouteState;
export declare const useIsCmsRoute: () => boolean;
export default CmsRouteHandler;
//# sourceMappingURL=CmsRouteHandler.d.ts.map