A modern personal blog built with Next.js 14, featuring MDX support, advanced search functionality, and dark mode.
π Live Demo: blog-next-gray-rho.vercel.app
- π MDX Support: Write content in Markdown with React components
- π Advanced Search: Fast local search with keyboard shortcuts (Cmd+K)
- π¨ Syntax Highlighting: Powered by Shiki with dual theme support
- π Dark Mode: System-aware dark/light theme switching
- π Math & Diagrams: LaTeX math expressions and Mermaid diagrams
- π± Responsive Design: Mobile-first responsive layout
- β‘ Performance: Optimized for speed and SEO
- π― Accessibility: WCAG compliant with keyboard navigation
- Framework: Next.js 15 (App Router)
- Language: TypeScript
- Content: MDX
- Styling: Tailwind CSS
- Animation: Motion
- Icons: @egoist/tailwindcss-icons
- Deployment: Vercel
- Node.js 18+
- pnpm (recommended) or npm
# Clone the repository
git clone <repository-url>
cd blog-next
# Install dependencies
pnpm install
# Generate search index
pnpm generate:search-index
# Start development server
pnpm dev# Development
pnpm dev # Start development server
pnpm build # Build for production
pnpm start # Start production server
pnpm lint # Run ESLint
# Search
pnpm generate:search-index # Generate search index- Create a new
.mdxfile in theposts/directory - Add frontmatter with metadata:
---
title: Your Post Title
summary: Brief description of your post
createdTime: 2024-01-01
tags: [tag1, tag2]
published: true
---- Write your content using Markdown and custom components
- Regenerate the search index:
pnpm generate:search-index
The blog supports various custom React components:
<>
<DarkToggle />
<LinkCard />
<LinkPreview />
<Mermaid />
</>;- Real-time Search: Instant results as you type
- Keyboard Shortcuts: Quick access with Cmd+K (Mac) or Ctrl+K (Windows/Linux)
- Smart Matching: Search across titles, content, and tags
- Highlighting: Visual emphasis on matching terms
- Responsive: Works seamlessly on all devices
-
Open Search Modal:
- Click the search icon in the navigation
- Use keyboard shortcut:
Cmd+K(Mac) orCtrl+K(Windows/Linux)
-
Navigate Results:
- Use arrow keys to navigate
- Press
Enterto open selected article - Press
Escto close
- Search Index: Generated from MDX frontmatter and content
- Local Search: Client-side search for fast performance
- API Endpoint:
/api/searchfor search queries - Components: Modal-based search interface
The blog provides RSS feed support for easy content subscription:
- RSS 2.0 Standard: Fully compliant RSS feed
- Auto-discovery: Browsers can automatically detect the RSS feed
- Latest Posts: Includes the 20 most recent articles
- Rich Content: Includes titles, descriptions, publication dates, and tags
- Caching: Optimized with 1-hour cache for better performance
- RSS Feed URL:
https://yourdomain.com/api/rss - RSS Page: Visit
/rssfor subscription instructions - Auto-discovery: Modern browsers will show RSS icon in address bar
- RSS Readers: Compatible with Feedly, Inoreader, NetNewsWire, etc.
- API Endpoint:
/api/feedgenerates XML feed - Auto-discovery: Added to HTML head for browser detection
- Content: Includes post summaries and metadata
- Navigation: RSS link added to main navigation
src/
βββ app/ # Next.js App Router
β βββ globals.css # Global styles
β βββ layout.tsx # Root layout
β βββ page.tsx # Home page
β βββ posts/ # Blog posts routes
β βββ api/ # API routes
βββ components/ # React components
β βββ ui/ # UI components
β βββ search/ # Search components
β βββ icons/ # Icon components
β βββ layout/ # Layout components
βββ lib/ # Utility functions
βββ hooks/ # Custom React hooks
βββ markdown/ # Markdown processing
βββ types/ # TypeScript definitions
posts/ # MDX blog posts
public/ # Static assets
βββ search-index.json # Generated search index
βββ ...
The blog uses a sophisticated markdown rendering pipeline:
- Markdown Parsing:
remark-parseconverts markdown to MDAST - Remark Plugins: Transform markdown (GFM, math, frontmatter)
- HTML Conversion:
remark-rehypeconverts to HAST - Rehype Plugins: Transform HTML (syntax highlighting, sanitization)
- React Rendering: Convert to React elements
- Syntax Highlighting: Shiki with theme support
- Math Expressions: KaTeX rendering
- Mermaid Diagrams: Interactive diagrams
- GitHub Alerts: Note, warning, tip callouts
- Code Copying: One-click code block copying
- Auto-generated TOC: Table of contents from headings
- Push your code to GitHub
- Connect your repository to Vercel
- Deploy automatically on every push
# Build the project
pnpm build
# Start production server
pnpm start- Code: Licensed under MIT
- Content: Licensed under CC BY-NC-SA 4.0
Inspired by:
Built with β€οΈ using Next.js and TypeScript