'use client'; import { useState, useEffect } from 'react'; import axios from 'axios'; import Link from 'next/link'; import IconArrowWaveLeftUp from '@/components/icon/icon-arrow-wave-left-up'; import IconRefresh from '@/components/icon/icon-refresh'; import IconCopy from '@/components/icon/icon-copy'; import IconDownload from '@/components/icon/icon-download'; import Loading from '@/components/layouts/loading'; import ReactMarkdown from 'react-markdown'; import remarkGfm from 'remark-gfm'; const BlogGenerator = () => { const [url, setUrl] = useState(''); const [loading, setLoading] = useState(false); const [blogData, setBlogData] = useState(null); const [error, setError] = useState(''); const [recentBlogs, setRecentBlogs] = useState([]); const [selectedEngine, setEngine] = useState('seomagnifier'); useEffect(() => { fetchRecentBlogs(); }, [url]); const fetchRecentBlogs = async () => { try { const { data } = await axios.get(`http://localhost:3020/api/blog/recent${url ? `?url=${encodeURIComponent(url)}` : ''}`); if (data.ok) { setRecentBlogs(data.data); } } catch (err) { console.error('Error fetching recent blogs:', err); } }; const handleGenerate = async () => { if (!url) return setError('Please enter a website URL'); setLoading(true); setError(''); setBlogData(null); try { const { data } = await axios.post('http://localhost:3020/api/blog/generate', { url, engine: selectedEngine }); if (data.ok) { setBlogData(data.data); fetchRecentBlogs(); } else { setError('Failed to generate content'); } } catch (err: any) { setError(err.response?.data?.error || err.message || 'Something went wrong'); } finally { setLoading(false); } }; const copyToClipboard = (text: string) => { navigator.clipboard.writeText(text); alert('Copied to clipboard!'); }; return (
{/* Header Section */}
One Click Expert Content
AI Blog Generator

Transform any website URL into an SEO-optimized, human-readable blog post in seconds.

setUrl(e.target.value)} placeholder="Enter Website URL (e.g., https://example.com)" className="form-input py-4 ltr:pr-[120px] rtl:pl-[120px] shadow-lg rounded-full border-2 border-primary/20 focus:border-primary transition-all text-lg" />
AI Engine:
{[ { id: 'seomagnifier', name: 'SEO Magnifier', icon: '🆓', sub: 'Unlimited' }, { id: 'ollama', name: 'Ollama', icon: '🏠', sub: 'Local' }, { id: 'openai', name: 'OpenAI', icon: '💎', sub: 'Premium' }, ].map((engine) => ( ))}
{error &&

{error}

}
{!blogData && !loading && (

Enter a URL above to start the magic.

We'll crawl the site, analyze its SEO structure, and build a custom blog for you.

)} {loading && (

Deep Auditing Website Structure...

Extracting semantic markers and entity relationships...

)} {blogData && (
{/* Main Blog Content Section */}

Generated Blog Post

View Full View

SEO Blueprint Info:

  • Meta Title: {blogData.metaTitle}
  • Meta Description: {blogData.metaDescription}
  • Focus Keyword: {blogData.focusKeyword}
{blogData.generatedImageUrls?.[0] && (
Generated blog header
AI Generated
)}

{blogData.title}

{blogData.content}
{/* Image Prompts Section */}

🎨 AI Image Prompts

{blogData.imagePrompts.map((prompt: string, i: number) => (

"{prompt}"

))}
{/* Sidebar Metrics/Analysis Section */}

Content Quality

SEO Optimization {blogData.seoScore}%
AI Detection (Human Score) {blogData.aiDetectionScore || 92}%
Human Readability {blogData.readabilityScore}%
Focus Keyword {blogData.focusKeyword || 'AI Optimized'}
{blogData.seoDetails && (

SEO Checklist

    {blogData.seoDetails.map((detail: string, i: number) => (
  • {detail}
  • ))}
)}

Internal Link Strategy

We've identified the high-authority endpoints to link from this blog post:

Primary Anchor

Link to "Solutions" page

Secondary Anchor

Link to "Our Process" deep dive

Power Up Your Content

Upgrade to Pro to unlock unlimited crawls and 100% genuine Gemini-powered content.

)}
{/* Recently Generated Blogs Sidebar */}

Recent Blogs

{recentBlogs.length === 0 ? (

No blogs generated yet {url ? 'for this URL' : ''}.

) : (
{recentBlogs.map((blog) => (
setBlogData(blog)} >

{blog.title}

{new Date(blog.createdAt).toLocaleDateString()} SEO: {blog.seoScore}%

{blog.url}

))}
)}

History is synced to your account.

); }; export default BlogGenerator;