Coding
PromptBeginner5 minmarkdown
Markdown Converter
Agent skill for markdown-converter
7
- Node.js 20(CI 使用,建议本地一致)
Sign in to like and favorite skills
##永远使用中文输出
@tailwindcss/postcss)src/app/(App Router)。每个路由目录保持自包含:page.tsx、layout.tsx、相关资源。src/app/globals.css;公共资源(图片、图标、robots 等)置于 public/。next.config.ts、tsconfig.json、eslint.config.mjs、postcss.config.mjs。.next/(已忽略),不要提交任何生成文件。@/* -> src/*(见 tsconfig.json 与 vitest.config.ts)。npm run dev — 使用 Turbopack 启动本地开发服务(http://localhost:3000)。npm run build — 编译生产构建(当前脚本包含 --turbopack)。npm run start — 以生产模式启动服务。npm run lint — 运行 ESLint(next/core-web-vitals + TypeScript 规则)。npm run test / npm run test:watch — 运行 Vitest 单测(JSDOM 环境,含 Testing Library)。npm run test:e2e — 运行 Playwright E2E(自动以 npm run dev 启动/复用本地服务)。HeroBanner.tsx);函数/变量:camelCase。src/app/(group)/feature/page.tsx。eslint.config.mjs 的扩展与忽略规则;修复问题或以注释说明原因。新增路由页面(推荐结构)
src/app/(group)/feature/page.tsx 与同级 layout.tsx// src/app/(marketing)/pricing/layout.tsx import type { Metadata } from 'next'; export const metadata: Metadata = { title: 'Pricing – PhotoFlow', description: 'Choose a plan that fits your workflow.', }; export default function PricingLayout({ children, }: Readonly<{ children: React.ReactNode }>) { return <section className="container mx-auto px-6 py-10">{children}</section>; }
// src/app/(marketing)/pricing/page.tsx export default function PricingPage() { return ( <div className="prose dark:prose-invert"> <h1 className="text-3xl font-bold">Pricing</h1> <p className="text-neutral-600">Choose a plan that fits your workflow.</p> </div> ); }
新增组件(含单测)
src/components/ComponentName.tsx 与 src/components/ComponentName.test.tsx// src/components/Callout.tsx 'use client'; type CalloutProps = { title: string; children?: React.ReactNode; }; export default function Callout({ title, children }: CalloutProps) { return ( <div className="rounded-md border border-neutral-200 dark:border-neutral-800 p-4"> <div className="text-sm font-semibold mb-2">{title}</div> {children ? <div className="text-sm text-neutral-600">{children}</div> : null} </div> ); }
// src/components/Callout.test.tsx import { render, screen } from '@testing-library/react'; import { describe, it, expect } from 'vitest'; import Callout from './Callout'; describe('Callout', () => { it('renders title and optional content', () => { render(<Callout title="Heads up">Content</Callout>); expect(screen.getByText('Heads up')).toBeInTheDocument(); expect(screen.getByText('Content')).toBeInTheDocument(); }); });
jsdom 环境),setupTests.ts 集成 @testing-library/jest-dom/vitest。playwright.config.ts,会复用/启动本地开发服务器)。*.test.ts、*.test.tsx(例如 src/components/Button.test.tsx)。e2e/ 目录(例如 e2e/home.spec.ts)。npx playwright install --with-deps 安装浏览器。feat:、fix:、chore: 等。示例:feat: add gallery grid layout。Closes #123)、带有视觉改动的截图、列出破坏性更改与配置/环境变量变更。npm run lint 与 npm run build 均通过;必要时补充/更新测试。.env.local;暴露给客户端的变量必须以 NEXT_PUBLIC_ 前缀命名。--turbopack:除非需求明确涉及构建策略调整,请保持脚本一致并在文档中注明差异。