A modern, fast, and feature-rich blog platform built with Next.js 14+, TypeScript, and MDX
π Live Demo β’ π Documentation β’ π― Features β’ π οΈ Quick Start β’ π API
- Real-time fuzzy search across all content with Fuse.js
- Keyboard shortcuts (βK / Ctrl+K) for quick access
- Smart suggestions with highlighted matches
- Mobile-optimized search experience
- Error boundary protection for graceful search failure recovery
- MDX support with custom components
- Syntax highlighting with multiple themes
- Auto-generated table of contents
- Enhanced tag system with categorized display (29 curated categories)
- Comprehensive tags page with color-coded sections and improved navigation
- Dynamic content metrics with auto-updating statistics
- Dynamic Open Graph images
- Content-aware distributed caching architecture - eliminates global edge cache inconsistency
- Smart ETag system with content-based hashing for precise cache invalidation
- Conservative caching strategy - 30min edge cache vs 24h stale-while-revalidate elimination
- Optimized ISR frequency - 24h revalidation matching weekly content updates (96% resource reduction)
- Bundle analysis with Next.js Bundle Analyzer (102kB baseline)
- Image optimization with WebP/AVIF format support and responsive sizing
- Error boundaries for graceful component failure recovery
- Production-tested MDX rendering with comprehensive error handling
- TypeScript strict mode for enhanced type safety
- ESLint strict rules for code quality enforcement
- 30-day image caching for optimal performance
- Static site generation for lightning-fast loading
- Critical bug protection - robust error handling prevents production crashes
- Responsive design with mobile-first approach
- Dark/Light theme toggle with system preference detection
- Shadcn/ui components for consistent design system
- Tailwind CSS for rapid styling
- Professional typography with @tailwindcss/typography
- Improved UI/UX with fixed sidebar positioning and better scroll behavior
- Enhanced navigation with tags integration in main and mobile menus
- Error-resilient UI with comprehensive error boundary implementation
- Error boundary system for graceful failure handling
- TypeScript strict mode with comprehensive type checking
- Zero ESLint warnings across the entire codebase
- Automated code quality checks with strict linting rules
- Performance monitoring foundation for continuous optimization
- TypeScript for type safety with strict mode enabled
- Feature-based architecture following 2025 best practices for scalable codebases
- Domain-driven organization - components grouped by business purpose, not technical type
- Clean import patterns with barrel exports and backward compatibility
- Bundle analysis tools with
npm run analyzecommand - Performance monitoring setup for optimization tracking
- ESLint & Prettier for code quality
- Git hooks for automated checks
- Hot reload in development
- One-click deployment to Vercel
- Node.js 18+
- npm, yarn, or pnpm
git clone https://github.com/liuyuelintop/next-blog.git
cd next-blog
npm installnpm run devOpen http://localhost:3000 to see your blog running locally.
Create a new MDX file in content/blog/:
---
title: "My First Post"
description: "This is my first blog post"
date: 2024-01-20
tags: ["tutorial", "getting-started"]
published: true
---
# Welcome to My Blog
This is my first post using **YuelinBlog**!- Docs index: docs/README.md
- Public API: docs/api/API_DOCS.md
- Archive: docs/archive/
| Technology | Purpose | Version | Optimization |
|---|---|---|---|
| Next.js | React framework with App Router | 15.5+ | Bundle analysis, Image optimization |
| TypeScript | Type safety and developer experience | 5.0+ | Strict mode enabled |
| Velite | Content management and MDX processing | 0.1.0-rc.3 | Build optimization |
| Tailwind CSS | Utility-first CSS framework | 3.4+ | Purged CSS |
| Shadcn/ui | React component library | Latest | Tree-shaking |
| Fuse.js | Fuzzy search functionality | 7.1+ | Error boundaries |
Feature-Based Architecture (2025 Best Practices)
βββ app/ # Next.js App Router pages
β βββ blog/ # Blog post pages
β βββ tags/ # Enhanced tag-based filtering with categories
β βββ about/ # Dynamic about page with auto-updating metrics
β βββ search/ # Search functionality with error boundaries
βββ components/ # Organized by business domain
β βββ features/ # Domain-specific components
β β βββ blog/ # Blog functionality (post-item, tag, pagination)
β β βββ search/ # Search functionality (input, results, error boundary)
β β βββ navigation/# Site navigation (header, footer, nav components)
β β βββ mdx/ # Content authoring (MDX components, callouts)
β βββ layout/ # Layout-specific components (providers, theme, errors)
β βββ ui/ # Pure reusable UI components (shadcn/ui)
β βββ icons.tsx # Global icon components
βββ hooks/ # Organized by domain
β βββ features/ # Feature-specific hooks
β β βββ search/ # Search domain hooks (search, cache, shortcuts)
β βββ ui/ # UI-specific hooks (copy buttons, etc.)
β βββ [general] # General-purpose hooks (blog stats, etc.)
βββ lib/ # Domain-specific utilities
β βββ utils/ # Organized utility functions
β β βββ ui.ts # UI utilities (className merging)
β β βββ formatting.ts # Date/text formatting
β β βββ blog.ts # Blog-specific utilities (sorting, tags, stats)
β βββ content/ # Content standards and tag validation system
β βββ [other libs] # Metadata, structured data, etc.
βββ content/ # MDX blog posts
β βββ blog/ # Individual post files
βββ styles/ # CSS and styling
βββ public/ # Static assets
Import Patterns:
// Feature-based imports (recommended for new code)
import { PostItem, Tag } from '@/components/features/blog';
import { useSearch } from '@/hooks/features/search';
import { cn } from '@/lib/utils/ui';
// Backward compatible imports (existing code continues working)
import { PostItem } from '@/components/features/blog/post-item';
import { cn, formatDate, getBlogStats } from '@/lib/utils';Edit config/site.ts to customize your blog:
export const siteConfig = {
name: "Your Blog Name",
url: "https://yourblog.com",
description: "Your blog description",
author: "Your Name",
links: {
github: "https://github.com/yourusername",
linkedin: "https://linkedin.com/in/yourprofile",
},
};Image optimization is configured in next.config.mjs:
export default {
images: {
formats: ['image/webp', 'image/avif'],
deviceSizes: [640, 750, 828, 1080, 1200, 1920, 2048, 3840],
imageSizes: [16, 32, 48, 64, 96, 128, 256, 384],
minimumCacheTTL: 60 * 60 * 24 * 30, // 30 days
},
};Blog posts use the following frontmatter:
---
title: string (max 99 chars)
description: string (max 999 chars, optional)
date: ISO date string
tags: array of strings (optional, max 4 tags recommended)
published: boolean (default: true)
---Lightweight, cache-friendly API with content-aware distributed caching for external consumption.
- Smart Content Detection: ETags based on actual content changes, not URL parameters
- Global Consistency: New articles visible worldwide within 30 minutes
- Zero Stale Content: Eliminated 24-hour stale-while-revalidate risk
- Optimized Resource Usage: 96% reduction in unnecessary ISR checks
GET /api/v1/feed?limit=6&tag=nextjsβ latest posts (no body), sorted by date descGET /api/v1/posts?page=1&per_page=10&tag=nextjsβ paginated listing (no body)GET /api/v1/healthβ service status, version, post count, content hash for cache validation
- ISR: 86400s (24h) - matches actual content update frequency
- HTTP Cache:
s-maxage=1800, max-age=300, must-revalidate- conservative 30min edge cache - ETag: Content-based MD5 hash for precise cache validation
- CORS:
Access-Control-Allow-Origin: *for GET requests
# Get latest posts with content hash validation
curl -s "https://<your-domain>/api/v1/feed?limit=6" | jq
# Check content version and service health
curl -s "https://<your-domain>/api/v1/health" | jq
# Paginated posts with smart caching
curl -s "https://<your-domain>/api/v1/posts?page=1&per_page=10" | jqWe welcome contributions! Please see our Contributing Guidelines for details.
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Make your changes and add tests
- Run performance analysis:
npm run analyze - Ensure code quality:
npm run lint - Test the build:
npm run build - Commit your changes:
git commit -m 'Add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request
- TypeScript strict mode compliance required
- Zero ESLint warnings before submitting
- Error boundary protection for new components
- Performance impact consideration for new features
- Production/CI: npm (default on Vercel). The npm lockfile is authoritative.
- Local development: you may use pnpm or bun for speed, but do not commit their lockfiles.
.gitignoreignorespnpm-lock.yamlandbun.lockto prevent accidental commits.
Found a bug or have a feature request? Please open an issue with:
- Clear description of the problem/feature
- Steps to reproduce (for bugs)
- Expected vs actual behavior
- Environment details
- Performance impact (if applicable)
This project is licensed under the MIT License - see the LICENSE file for details.
- Next.js Bundle Analyzer - Bundle optimization tools
- Web Vitals - Performance metrics guidance
- React Error Boundaries - Error handling patterns
- Velite.js - Excellent content management solution
- Next.js - The React framework that powers this blog
- Vercel - For seamless deployment and hosting
- Jolly Coding - For the initial tutorial foundation
- All contributors who have helped improve this project's performance and quality
- Live Demo: blog.liuyuelin.dev
- Author Portfolio: liuyuelin.dev
- Author GitHub: @liuyuelintop
- Author LinkedIn: liuyuelintop
Built with β€οΈ and optimized for performance by Yuelin Liu
If this project helped you, please consider giving it a βοΈ!