Next.jsReact博客

next-blog — Next.js 博客模板

作者 liuyuelintop

基于 Next.js App Router、TypeScript 与 Velite/MDX 的开发者博客模板,内置 Fuse.js 模糊搜索、标签分类、动态 OG 图片与公开 API。

看看你的网站会是什么样

浏览真实页面截图,比较内容排版与手机效果。点击下方缩略图切换,放大查看整页细节。

3 个预览视图
桌面端首页1 / 3
桌面端截图首屏预览

由服务器浏览器实际访问页面后截取。

全部页面与视图 3

截图用于了解视觉与布局,交互效果请以实际项目为准。

采集于 2026-10-14查看来源

值得关注的模板亮点

从已有项目资料中,快速了解它的特点。

01

使用 Velite 处理 MDX 内容,支持自定义组件、语法高亮与自动目录

02

Fuse.js 实时模糊搜索,支持 ⌘K/Ctrl+K 快捷键与移动端

03

标签系统按分类展示,标签页带颜色分区

04

提供 /api/v1/feed、/api/v1/posts、/api/v1/health 公开接口

05

基于内容哈希的 ETag 与保守缓存策略,README 说明边缘缓存 30 分钟

06

按业务域组织的组件、hooks 与 lib 目录结构

模板详细介绍

这是一个用 Next.js App Router、TypeScript、Tailwind CSS 与 Velite 处理 MDX 内容的开发者博客模板。文章以 MDX 文件形式存放在 content/blog/ 目录,通过 frontmatter 定义标题、描述、日期、标签与发布状态,支持自定义 MDX 组件、语法高亮和自动生成目录。搜索基于 Fuse.js,支持实时模糊匹配、⌘K/Ctrl+K 快捷键和移动端适配,并配有错误边界。标签系统提供分类展示,站点配置集中在 config/site.ts,图片优化参数在 next.config.mjs 中设置。模板还提供 /api/v1/feed、/api/v1/posts 与 /api/v1/health 三个公开接口,README 说明其采用基于内容哈希的 ETag 与 30 分钟边缘缓存策略。README 未提供主题定制、评论、订阅或数据库等功能的说明,也未说明除 Vercel 之外的其他部署方式。

Next.js博客

适合你的项目吗?

适用场景

  • 搭建个人开发者博客并发布 MDX 技术文章
  • 需要站内模糊搜索与标签筛选的内容站点
  • 为外部应用提供文章列表 JSON 接口的博客
  • 部署到 Vercel 的静态内容站点

适合人群

  • 熟悉 Next.js App Router 与 TypeScript 的开发者
  • 以 MDX 文件作为内容来源的博客作者
  • 需要公开文章 API 供第三方读取的站点维护者

上手与定制指南

结合仓库当前版本的说明,按下面的资料检查内容、配置与运行要求。

  1. 1

    环境要求 Node.js 18+,使用 npm install 安装依赖,npm run dev 本地启动

  2. 2

    在 content/blog/ 下新建 MDX 文件,按 frontmatter 填写 title、date、tags、published 等字段

  3. 3

    站点名称、URL、作者与社交链接在 config/site.ts 中修改

  4. 4

    图片格式与缓存参数在 next.config.mjs 的 images 字段中配置

  5. 5

    README 提供 Vercel 一键部署按钮,未说明其他部署方式

查看仓库使用说明

授权与来源资料

使用条件与限制

免费使用 · 保留许可声明

本次收录的是公开仓库中采用 MIT 许可的免费版本;免费范围为该版本代码,不代表外部服务或第三方素材免费。

使用时需要遵守

  • 允许免费使用、修改、商用和分发该版本代码。
  • 分发代码副本或实质性部分时,保留原作者版权声明和完整 MIT 许可声明。
  • 代码按现状提供;担保与责任限制以原许可证及适用法律为准。

额外费用与待核对事项

  • 演示图片、字体、图标及其他第三方素材需按各自许可核对,不能仅凭代码的 MIT 许可判断。
  • 域名、托管、数据库、支付或 AI 等外部服务可能另外收费。
  • 生产/CI 环境必须使用 npm,npm 锁文件为权威依赖来源。
  • 本地开发可用 pnpm 或 bun,但不得提交其锁文件。
  • .gitignore 忽略 pnpm-lock.yaml 与 bun.lock,防止误提交。
  • README 仅提供 Vercel 一键部署,未说明其他部署方式。
  • 运行环境要求 Node.js 18 及以上。
查看原文依据

Permission is hereby granted, free of charge

许可证原文

- Production/CI: npm (default on Vercel). The npm lockfile is authoritative.

README 原文

- Local development: you may use pnpm or bun for speed, but do not commit their lockfiles.

README 原文

- `.gitignore` ignores `pnpm-lock.yaml` and `bun.lock` to prevent accidental commits.

README 原文

- **One-click deployment** to Vercel

README 原文

- Node.js 18+

README 原文
https://github.com/liuyuelintop/next-blog/blob/main/LICENSEhttps://github.com/liuyuelintop/next-blog/blob/main/README.md

DeepSeek 根据仓库许可证和 README 整理 ·2026-10-14。结果仅覆盖已读取资料,依赖、图片、字体及后续条款变更以各自原文为准。

项目核对记录与介绍依据

模板资料

来源平台
GitHub
资料与维护参考分
资料较完整 · 77 / 100
技术栈
Next.js · React
网站类型
博客
这个分数如何计算

本站按许可资料(最高30分)、演示链接(12分)、预览图(10分)、Star数(15分)、记录的维护时间(15分)、描述完整度(8分)、功能记录(5分)和分类资料(5分)计算。它不是代码、安全或性能测试,也不是 Google 评分;有链接不代表已实测可用。

这个项目需要核对什么

记录的仓库更新时间
2025-09-28
截图检查日期
2026-10-14

已收录演示链接。请用你的内容与屏幕尺寸检查;有演示不代表表单、认证或支付已经可用。

目录记录的主要技术栈是 Next.js。请通过依赖清单和锁文件核对实际版本与托管要求。这些说明基于收录资料,不代表代码审计或部署实测。

查看具体选型方法 →

介绍的制作与核对状态

介绍由 AI 辅助整理目录与仓库资料。仓库作者不等于这篇介绍的审核者。

审核声明: codex-user-requested-batch-review-20261015 · 2026-10-15

查看当时使用的来源资料

SHA-256: 012095c8bed94ec10465c663baf525993359979e20117e85d30506ab8f102a1f

2026-10-14T00:03:51.925Z

来源文件 / 仓库
# YuelinBlog - Modern Developer Blog Platform

<div align="center">

![Next.js](https://img.shields.io/badge/Next.js-15.5-black?style=for-the-badge&logo=next.js)
![TypeScript](https://img.shields.io/badge/TypeScript-5.0-blue?style=for-the-badge&logo=typescript)
![Tailwind CSS](https://img.shields.io/badge/Tailwind-3.4-38B2AC?style=for-the-badge&logo=tailwind-css)
![Velite](https://img.shields.io/badge/Velite-MDX-orange?style=for-the-badge)
![License](https://img.shields.io/badge/License-MIT-green?style=for-the-badge)
![Performance](https://img.shields.io/badge/Performance-Optimized-brightgreen?style=for-the-badge)

**A modern, fast, and feature-rich blog platform built with Next.js 14+, TypeScript, and MDX**

[🚀 **Live Demo**](https://blog.liuyuelin.dev/) • [📚 **Documentation**](#documentation) • [🎯 **Features**](#features) • [🛠️ **Quick Start**](#quick-start) • [🔌 **API**](#public-api)

</div>

---

## ✨ Features

### 🔍 **Advanced Search**

- **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

### 📝 **Content Management**

- **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

### ⚡ **Performance & Reliability**

- **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

### 🎨 **Modern Design**

- **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

### 🛡️ **Reliability & Quality**

- **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

### 🛠️ **Developer Experience**

- **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 analyze` command
- **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

---

 

## 🚀 Quick Start

### Prerequisites

- Node.js 18+
- npm, yarn, or pnpm

### 1. Clone & Install

```bash
git clone https://github.com/liuyuelintop/next-blog.git
cd next-blog
npm install
```

### 2. Development

```bash
npm run dev
```

Open [http://localhost:3000](http://localhost:3000) to see your blog running locally.

### 3. Create Your First Post

Create a new MDX file in `content/blog/`:

```markdown
---
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**!
```

### 4. Deploy to Vercel

[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https://github.com/liuyuelintop/next-blog)

---

## 📖 Documentation

- Docs index: [docs/README.md](docs/README.md)
- Public API: [docs/api/API_DOCS.md](docs/api/API_DOCS.md)
- Archive: [docs/archive/](docs/archive)

### Tech Stack

| 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 |

### Project Structure

**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:**
```typescript
// 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';
```

 

### Configuration

#### Site Configuration

Edit `config/site.ts` to customize your blog:

```typescript
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",
  },
};
```

#### Performance Configuration

Image optimization is configured in `next.config.mjs`:

```javascript
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
  },
};
```

#### Content Schema

Blog posts use the following frontmatter:

```yaml
---
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)
---
```

## Public API

Lightweight, cache-friendly API with **content-aware distributed caching** for external consumption.

### **🚀 New Content-Aware Caching Architecture**

- **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

### **📍 Endpoints**

- `GET /api/v1/feed?limit=6&tag=nextjs` — latest posts (no body), sorted by date desc
- `GET /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**

### **⚡ Caching & Performance**

- **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

### **💡 Examples**

```bash
# 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" | jq
```

 

---

 

## 🤝 Contributing

We welcome contributions! Please see our [Contributing Guidelines](CONTRIBUTING.md) for details.

### Development Workflow

1. Fork the repository
2. Create a feature branch: `git checkout -b feature/amazing-feature`
3. Make your changes and add tests
4. Run performance analysis: `npm run analyze`
5. Ensure code quality: `npm run lint`
6. Test the build: `npm run build`
7. Commit your changes: `git commit -m 'Add amazing feature'`
8. Push to the branch: `git push origin feature/amazing-feature`
9. Open a Pull Request

### Code Quality Standards

- **TypeScript strict mode** compliance required
- **Zero ESLint warnings** before submitting
- **Error boundary protection** for new components
- **Performance impact** consideration for new features

### Package Manager Policy

- 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.
- `.gitignore` ignores `pnpm-lock.yaml` and `bun.lock` to prevent accidental commits.

### Reporting Issues

Found a bug or have a feature request? Please [open an issue](https://github.com/liuyuelintop/next-blog/issues) with:

- Clear description of the problem/feature
- Steps to reproduce (for bugs)
- Expected vs actual behavior
- Environment details
- Performance impact (if applicable)

---

## 📝 License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

---

## 🙏 Acknowledgments

### Design Inspiration

- [Shadcn](https://ui.shadcn.com/) - For the beautiful component design system
- [Taxonomy](https://tx.shadcn.com/) - For layout and structure inspiration

### Performance & Optimization

- [Next.js Bundle Analyzer](https://www.npmjs.com/package/@next/bundle-analyzer) - Bundle optimization tools
- [Web Vitals](https://web.dev/vitals/) - Performance metrics guidance
- [React Error Boundaries](https://react.dev/reference/react/Component#catching-rendering-errors-with-an-error-boundary) - Error handling patterns

### Community

- [Velite.js](https://velite.js.org/) - Excellent content management solution
- [Next.js](https://nextjs.org/) - The React framework that powers this blog
- [Vercel](https://vercel.com/) - For seamless deployment and hosting

### Special Thanks

- [Jolly Coding](https://www.youtube.com/@JollyCoding) - For the initial tutorial foundation
- All contributors who have helped improve this project's performance and quality

---

## 🔗 Links

- **Live Demo**: [blog.liuyuelin.dev](https://blog.liuyuelin.dev/)
- **Author Portfolio**: [liuyuelin.dev](https://liuyuelin.dev/)
- **Author GitHub**: [@liuyuelintop](https://github.com/liuyuelintop)
- **Author LinkedIn**: [liuyuelintop](https://www.linkedin.com/in/liuyuelintop/)

---

<div align="center">

**Built with ❤️ and optimized for performance by [Yuelin Liu](https://liuyuelin.dev)**

If this project helped you, please consider giving it a ⭐️!

</div>
反馈内容错误

看看同类模板

对比同技术栈与用途的模板,找到更适合的视觉与内容结构。