@ai-growth/nextjs
Version:
Seamlessly integrate Sanity CMS with Next.js applications for automated blog routing and rendering
24 lines (23 loc) • 1.78 kB
JavaScript
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { DefaultTemplate } from '../components/DefaultTemplate';
/**
* ContentTemplate - An enhanced template for rendering CMS content
*
* Features:
* - Properly handles null/empty content with a user-friendly message
* - Uses the existing DefaultTemplate for standard content rendering
* - Adds improved empty state displays
*/
export const ContentTemplate = (props) => {
const { content } = props;
// When content exists but content.content is null/empty
if (content && (content.content === null ||
(Array.isArray(content.content) && content.content.length === 0) ||
content.content === undefined)) {
return (_jsx("div", { className: "max-w-4xl mx-auto", children: _jsxs("div", { className: "bg-yellow-50 border border-yellow-200 rounded-lg p-6 text-center", children: [_jsx("div", { className: "text-yellow-600 mb-2", children: _jsx("svg", { className: "w-8 h-8 mx-auto mb-2", fill: "currentColor", viewBox: "0 0 20 20", children: _jsx("path", { fillRule: "evenodd", d: "M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z", clipRule: "evenodd" }) }) }), _jsx("h3", { className: "text-lg font-medium text-yellow-800 mb-1", children: "Conte\u00FAdo em desenvolvimento" }), _jsx("p", { children: "Este post existe mas ainda n\u00E3o possui conte\u00FAdo. Volte em breve!" })] }) }));
}
// For completely missing content, loading state, or error,
// just delegate to the DefaultTemplate which already handles these cases
return _jsx(DefaultTemplate, { ...props });
};
export default ContentTemplate;