A beautiful, production-ready blog CMS built with Next.js 14, featuring a forest-themed design that connects people through storytelling.
- Modern Tech Stack: Next.js 14 with App Router, React 18, TypeScript, Tailwind CSS
- Authentication: Google OAuth integration with NextAuth.js
- Content Management: Full CRUD operations for blog posts with admin approval workflow
- Rich Content: Markdown support with image handling and reading time calculation
- Interactive Features: Heart system, commenting, and real-time engagement
- Responsive Design: Mobile-first approach with beautiful forest-themed UI
- Post Creation: Rich text editor with markdown support, image uploads, and tagging
- Social Engagement: Heart posts, comment system, and author profiles
- Personal Dashboard: Track your posts, hearts received, and engagement metrics
- Rate Limiting: 5 posts per day limit to maintain quality
- Content Moderation: Approve/reject posts with custom feedback
- User Management: Monitor user activity and engagement
- Analytics: Track post performance and community growth
- Email Notifications: Automated approval/rejection emails
- Server-Side Rendering: Optimized for search engines and performance
- Meta Tags: Dynamic Open Graph and Twitter card generation
- Sitemap: Auto-generated sitemap.xml for better indexing
- Image Optimization: Next.js Image component with Pexels integration
- Node.js 18+ and npm
- MongoDB database
- Google OAuth credentials
- SMTP email service (optional)
- Clone and install dependencies
git clone <repository-url>
cd forest-blog
npm install- Environment Setup
Copy
.env.local.exampleto.env.localand fill in your credentials:
# Database
MONGODB_URI=mongodb://localhost:27017/blogcms
# NextAuth
NEXTAUTH_URL=http://localhost:3000
NEXTAUTH_SECRET=your-secret-key-here
# Google OAuth
GOOGLE_CLIENT_ID=your-google-client-id
GOOGLE_CLIENT_SECRET=your-google-client-secret
# Cloudinary (for image uploads)
CLOUDINARY_CLOUD_NAME=your-cloudinary-name
CLOUDINARY_API_KEY=your-cloudinary-key
CLOUDINARY_API_SECRET=your-cloudinary-secret
# Email (optional)
SMTP_HOST=smtp.gmail.com
SMTP_PORT=587
SMTP_USER=[email protected]
SMTP_PASS=your-email-password- Get Required Credentials
- Go to Google Cloud Console
- Create a new project or select existing
- Enable Google+ API
- Create OAuth 2.0 credentials
- Add authorized redirect URIs:
http://localhost:3000/api/auth/callback/google(development)https://yourdomain.com/api/auth/callback/google(production)
- Local: Install MongoDB locally or use Docker
- Cloud: Use MongoDB Atlas (free tier available)
- Go to Cloudinary and create a free account
- From your dashboard, copy:
- Cloud Name
- API Key
- API Secret
- Add these to your
.env.localfile
- Use Gmail, SendGrid, or any SMTP provider
- For Gmail: Enable 2FA and use App Password
- Run the development server
npm run dev- Build for production
npm run build
npm startforest-blog/
βββ app/ # Next.js 14 App Router
β βββ (auth)/
β β βββ auth/ # Authentication pages
β βββ admin/ # Admin dashboard
β βββ create/ # Post creation
β βββ posts/ # Blog post pages
β βββ profile/ # User profile
β βββ api/ # API routes
β β βββ auth/ # NextAuth endpoints
β β βββ posts/ # Post CRUD operations
β β βββ admin/ # Admin operations
β β βββ user/ # User operations
β βββ globals.css # Global styles
β βββ layout.tsx # Root layout
β βββ page.tsx # Home page
βββ components/ # Reusable UI components
β βββ ui/ # shadcn/ui components
β βββ AuthProvider.tsx # Authentication context
β βββ Navbar.tsx # Navigation component
β βββ Hero.tsx # Hero section
β βββ PostGrid.tsx # Post grid display
β βββ PostActions.tsx # Heart/comment actions
β βββ CommentSection.tsx # Comments functionality
βββ lib/ # Utility libraries
β βββ models/ # MongoDB models
β β βββ User.ts # User model
β β βββ Post.ts # Post model
β β βββ Heart.ts # Heart model
β βββ utils/ # Utility functions
β β βββ email.ts # Email notifications
β β βββ reading-time.ts # Reading time calculation
β βββ validations/ # Zod schemas
β β βββ post.ts # Post validation
β βββ auth.ts # NextAuth configuration
β βββ mongodb.ts # Database connection
β βββ utils.ts # General utilities
βββ public/ # Static asset dir
β βββ images/ # Images folder
β β βββ user.png # Default user image
βββ .env.local.example # Environment variables template
βββ next.config.js # Next.js configuration
βββ tailwind.config.ts # Tailwind CSS configuration
βββ tsconfig.json # TypeScript configuration
βββ README.md # This file
/** @type {import('next').NextConfig} */
const nextConfig = {
experimental: {
appDir: true,
},
images: {
domains: ['lh3.googleusercontent.com', 'res.cloudinary.com'],
},
env: {
NEXTAUTH_URL: process.env.NEXTAUTH_URL,
NEXTAUTH_SECRET: process.env.NEXTAUTH_SECRET,
},
};
module.exports = nextConfig;Configured with custom color palette for forest theme, animations, and shadcn/ui integration.
- Connect your GitHub repository to Vercel
- Add environment variables in Vercel dashboard
- Deploy automatically on push to main branch
- Build command:
npm run build - Publish directory:
out - Add environment variables in Netlify dashboard
FROM node:18-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY . .
RUN npm run build
EXPOSE 3000
CMD ["npm", "start"]- Connect GitHub repository
- Set build command:
npm run build - Set start command:
npm start - Add environment variables
- Dynamic Meta Tags: Title, description, and Open Graph for each page
- Structured Data: JSON-LD schema for blog posts
- Sitemap Generation: Auto-generated sitemap.xml
- Robots.txt: SEO-friendly crawler instructions
- Image Optimization: Cloudinary integration with Next.js Image component
- Server-Side Rendering: Fast page loads and SEO-friendly content
- Verify meta tags are properly generated
- Test sitemap.xml accessibility
- Check robots.txt configuration
- Validate structured data with Google's Rich Results Test
- Test page load speeds with PageSpeed Insights
- Verify mobile responsiveness
# Run development server
npm run dev
# Build for production
npm run build
# Start production server
npm start
# Lint code
npm run lint
# Type checking
npx tsc --noEmit- Authentication: Secure Google OAuth integration
- Input Validation: Zod schema validation on client and server
- Rate Limiting: Post creation limits to prevent spam
- Content Sanitization: Markdown content sanitization
- File Upload Security: File type and size validation for images
- CSRF Protection: NextAuth.js built-in CSRF protection
- Environment Variables: Secure credential management
- Primary: Amber (600-900) - Warm, earthy tones
- Secondary: Green (400-600) - Fresh forest greens
- Accent: Red (500) - Hearts and important actions
- Neutral: Gray (100-900) - Text and backgrounds
- Font: Inter (Google Fonts)
- Headings: Bold, amber-900
- Body: Regular, amber-700
- Captions: Small, amber-600
- Cards: Subtle shadows with backdrop blur
- Buttons: Rounded, good contrast ratios
- Forms: Amber borders with focus states
- Navigation: Sticky header with forest gradient
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Commit changes:
git commit -m 'Add amazing feature' - Push to branch:
git push origin feature/amazing-feature - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Next.js Team - For the amazing framework
- Vercel - For hosting and deployment tools
- shadcn/ui - For beautiful, accessible UI components
- Cloudinary - For image storage and optimization
- Pexels - For high-quality stock images
- MongoDB - For the database solution
Built with β€οΈ by the Forest Blog Team
Connecting nature lovers through the power of storytelling