import React, { useState, useEffect } from 'react'; import type { BlogPost } from '../../../types'; import { apiClient } from '../../../lib/api-client'; import { useAuth } from '../../auth/store/AuthContext'; import { BookOpen, User, Calendar, Clock, Plus, X, Sparkles, Send } from 'lucide-react'; export const BlogCatalog: React.FC = () => { const { user } = useAuth(); const [posts, setPosts] = useState([]); const [loading, setLoading] = useState(true); const isAdmin = user?.role === 'ADMIN'; // CMS modal state const [isOpen, setIsOpen] = useState(false); const [title, setTitle] = useState(''); const [content, setContent] = useState(''); const [tagsInput, setTagsInput] = useState(''); const [thumbnailUrl, setThumbnailUrl] = useState(''); const [status, setStatus] = useState<'draft' | 'published'>('draft'); const [formError, setFormError] = useState(''); const [submitting, setSubmitting] = useState(false); const fetchPosts = async () => { setLoading(true); try { const response = await apiClient.get('/blog'); setPosts(response.data); } catch (err) { console.error(err); } finally { setLoading(false); } }; useEffect(() => { fetchPosts(); }, []); const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); setFormError(''); if (!title.trim() || !content.trim()) { setFormError('Title and content are required.'); return; } setSubmitting(true); try { const tags = tagsInput.split(',').map(t => t.trim()).filter(t => t.length > 0); const payload = { title, content, tags, thumbnailUrl: thumbnailUrl.trim() || undefined, status, author: 'Technical Architect', }; const response = await apiClient.post('/blog/new', payload); setPosts(prev => [response.data, ...prev]); setTitle(''); setContent(''); setTagsInput(''); setThumbnailUrl(''); setStatus('draft'); setIsOpen(false); } catch (err) { setFormError('Failed to publish article.'); } finally { setSubmitting(false); } }; return (

Engineering Blog & Insights

Deep-dives into RISC-V pipelining, CodeNuk scaffolding practices, and edge security optimizations.

{isAdmin && ( )}
{loading ? (
{[1, 2].map(n => (
))}
) : posts.length === 0 ? (

No blog posts published yet.

) : (
{posts.map(post => (
{post.title} {isAdmin && ( {post.status} )}
{post.author} {post.publishDate} {post.readTime}

{post.title}

{post.content}

{post.tags.map(t => ( #{t} ))}
))}
)} {/* Post Creator Modal */} {isOpen && (

Write Blog Article

Draft or publish a technical write-up for the developer channel.

{formError && (
{formError}
)}
setTitle(e.target.value)} placeholder="e.g. Optimizing Pipeline Hazards in RV64GC Core Designs" className="w-full rounded-lg border border-ink-200 px-3.5 py-2 text-sm focus:border-ink-900/50 focus:outline-none bg-ink-50 text-ink-900 placeholder-ink-400" required />