- Node.js >= 16.0.0
- npm >= 8.0.0
- Git
# 克隆项目
git clone <repository-url>
cd NotionNext
# 初始化开发环境
npm run init-dev
# 启动开发服务器
npm run dev# 代码格式化
npm run format
# 代码检查
npm run lint
# 类型检查
npm run type-check
# 完整质量检查
npm run quality
# 预提交检查
npm run pre-commit# 查看所有开发工具命令
npm run dev-tools
# 清理项目文件
npm run clean
# 生成组件模板
npm run dev-tools generate:component MyComponent
# 分析包大小
npm run dev-tools analyze
# 检查依赖更新
npm run check-updates
# 生成项目文档
npm run docs# 安装Git钩子
npm run setup-hooks
# 检查钩子状态
npm run check-hooks
# 移除Git钩子
npm run remove-hooksNotionNext/
├── components/ # React组件
├── pages/ # Next.js页面
├── lib/ # 工具库和配置
│ ├── config/ # 配置文件
│ ├── utils/ # 工具函数
│ ├── middleware/ # 中间件
│ └── cache/ # 缓存相关
├── themes/ # 主题文件
├── conf/ # 配置文件
├── scripts/ # 构建和开发脚本
├── types/ # TypeScript类型定义
├── .vscode/ # VSCode配置
└── docs/ # 项目文档
- 使用 Prettier 进行代码格式化
- 使用 ESLint 进行代码检查
- 使用 TypeScript 进行类型检查
- 遵循 React Hooks 最佳实践
- 组件: PascalCase (例:
LazyImage) - 文件: kebab-case (例:
lazy-image.js) - 变量/函数: camelCase (例:
getUserData) - 常量: UPPER_SNAKE_CASE (例:
API_BASE_URL)
使用 Conventional Commits 规范:
<type>(<scope>): <description>
[optional body]
[optional footer]
类型 (type):
feat: 新功能fix: 修复bugdocs: 文档更新style: 代码格式化refactor: 代码重构test: 测试相关chore: 构建工具或辅助工具的变动perf: 性能优化ci: CI配置文件和脚本的变动build: 影响构建系统或外部依赖的更改revert: 回滚之前的提交
示例:
feat(auth): add user authentication
fix(ui): resolve button alignment issue
docs: update installation guide
git checkout -b feature/your-feature-name# 启动开发服务器
npm run dev
# 运行代码质量检查
npm run quality
# 运行测试
npm test# 添加文件
git add .
# 提交(会自动运行pre-commit钩子)
git commit -m "feat: add new feature"# 推送(会自动运行pre-push钩子)
git push origin feature/your-feature-name项目已配置VSCode调试环境,支持以下调试模式:
- Next.js: debug server-side - 调试服务端代码
- Next.js: debug client-side - 调试客户端代码
- Next.js: debug full stack - 全栈调试
- Jest: debug tests - 调试测试
# 启动调试模式
npm run dev
# 在浏览器中打开开发者工具
# 访问 http://localhost:3000# 分析包大小
npm run bundle-report
# 生成性能报告
npm run analyzeNOTION_PAGE_ID: Notion页面ID
NEXT_PUBLIC_TITLE: 网站标题NEXT_PUBLIC_DESCRIPTION: 网站描述NEXT_PUBLIC_AUTHOR: 作者名称NEXT_PUBLIC_LINK: 网站链接
# 验证环境变量配置
npm run quality# 清理缓存
npm run clean
rm -rf node_modules package-lock.json
# 重新安装
npm install# 检查代码质量
npm run quality
# 清理并重新构建
npm run clean
npm run build# 运行类型检查
npm run type-check
# 查看详细错误信息
npx tsc --noEmit --pretty# 自动修复ESLint错误
npm run lint:fix
# 查看所有ESLint规则
npx eslint --print-config .- Fork 项目
- 创建功能分支
- 提交更改
- 推送到分支
- 创建 Pull Request
- 代码通过所有质量检查
- 包含适当的测试
- 更新相关文档
- 遵循提交规范
- 查看项目文档:
npm run docs - 检查开发工具:
npm run dev-tools - 提交 Issue 或 Pull Request