Claude Code के साथ Blog CMS कैसे बनाएं
Claude Code का उपयोग करके blog CMS बनाना सीखें। Practical code examples और step-by-step guidance शामिल है।
Claude Code से Blog CMS बनाएं
अपना खुद का blog CMS रखने से design freedom, SEO control, और performance optimization पर पूरा control मिलता है। Claude Code का उपयोग करके, article management, preview, और publishing workflow वाला CMS कम समय में बनाया जा सकता है।
Prompt Design
> Next.js App Router से blog CMS बनाओ।
> Markdown articles create, edit, publish कर सकने वाली admin panel और
> SSG से generate होने वाला frontend दोनों बनाओ।
> Category और tags से filtering भी implement करो।
Article Data Model Definition
// src/types/post.ts
export interface Post {
id: string;
title: string;
slug: string;
content: string; // Markdown
excerpt: string;
coverImage?: string;
category: string;
tags: string[];
status: 'draft' | 'published' | 'archived';
publishedAt?: Date;
createdAt: Date;
updatedAt: Date;
authorId: string;
}
export interface PostCreateInput {
title: string;
content: string;
category: string;
tags: string[];
status?: 'draft' | 'published';
}
Article Management API Implementation
// src/app/api/posts/route.ts
import { NextRequest, NextResponse } from 'next/server';
import { prisma } from '@/lib/prisma';
import { generateSlug } from '@/lib/utils';
export async function GET(request: NextRequest) {
const { searchParams } = new URL(request.url);
const category = searchParams.get('category');
const tag = searchParams.get('tag');
const status = searchParams.get('status') || 'published';
const posts = await prisma.post.findMany({
where: {
status,
...(category && { category }),
...(tag && { tags: { has: tag } }),
},
orderBy: { publishedAt: 'desc' },
select: {
id: true,
title: true,
slug: true,
excerpt: true,
category: true,
tags: true,
publishedAt: true,
coverImage: true,
},
});
return NextResponse.json(posts);
}
export async function POST(request: NextRequest) {
const body = await request.json();
const slug = generateSlug(body.title);
const post = await prisma.post.create({
data: {
...body,
slug,
excerpt: body.content.substring(0, 160),
publishedAt: body.status === 'published' ? new Date() : null,
},
});
return NextResponse.json(post, { status: 201 });
}
Markdown Editor Component
// src/components/admin/MarkdownEditor.tsx
'use client';
import { useState } from 'react';
import ReactMarkdown from 'react-markdown';
import remarkGfm from 'remark-gfm';
interface Props {
initialContent?: string;
onSave: (content: string) => void;
}
export function MarkdownEditor({ initialContent = '', onSave }: Props) {
const [content, setContent] = useState(initialContent);
const [isPreview, setIsPreview] = useState(false);
return (
<div className="border rounded-lg">
<div className="flex border-b">
<button
onClick={() => setIsPreview(false)}
className={`px-4 py-2 ${!isPreview ? 'bg-blue-50 font-bold' : ''}`}
>
Edit
</button>
<button
onClick={() => setIsPreview(true)}
className={`px-4 py-2 ${isPreview ? 'bg-blue-50 font-bold' : ''}`}
>
Preview
</button>
</div>
{isPreview ? (
<div className="prose p-4 max-w-none">
<ReactMarkdown remarkPlugins={[remarkGfm]}>{content}</ReactMarkdown>
</div>
) : (
<textarea
value={content}
onChange={(e) => setContent(e.target.value)}
className="w-full h-96 p-4 font-mono text-sm resize-none"
placeholder="Markdown में article लिखें..."
/>
)}
<div className="flex justify-end p-3 border-t">
<button
onClick={() => onSave(content)}
className="bg-blue-600 text-white px-6 py-2 rounded"
>
Save
</button>
</div>
</div>
);
}
SEO Metadata Auto-Generation
Claude Code से request करने पर article content से OGP image auto-generation और meta tags setup भी implement किया जा सकता है।
// src/lib/seo.ts
export function generatePostMeta(post: Post) {
return {
title: `${post.title} | MyBlog`,
description: post.excerpt,
openGraph: {
title: post.title,
description: post.excerpt,
type: 'article',
publishedTime: post.publishedAt?.toISOString(),
tags: post.tags,
images: post.coverImage ? [{ url: post.coverImage }] : [],
},
};
}
Related Articles
CMS construction के frontend part के लिए SSR/SSG Comparison Guide helpful है। SEO measures के लिए SEO Optimization भी check करें।
Markdown processing library selection के लिए unified.js ecosystem comprehensive है और reference के रूप में useful है।
Related Posts
Claude Code से अपने Side Projects को Supercharge कैसे करें [Examples के साथ]
Claude Code से personal development projects को dramatically speed up करना सीखें। Real-world examples और idea से deployment तक practical workflow शामिल है।
Claude Code से Refactoring कैसे Automate करें
Claude Code से efficiently code refactoring automate करना सीखें। Real-world projects के लिए practical prompts और concrete refactoring patterns शामिल हैं।
Claude Code के साथ Complete CORS Configuration Guide
Claude Code का उपयोग करके complete CORS configuration guide सीखें। Practical tips और code examples शामिल हैं।