Project Setup Documentation
Initial Setup
-
Package Manager Configuration
"packageManager": "[email protected]",
"overrides": {
"react": "$react",
"react-dom": "$react-dom"
}
-
ShadCN UI Installation
npx shadcn@latest
Sanity CMS Setup
-
Create Sanity Project
npm create sanity@latest -- --project flfshs5n --dataset production --template clean --typescript --output-path studio-jsm-yc_directory
cd studio-jsm-yc_directory
-
Next.js Integration
npm i next-sanity@canary
-
Important Note
- Remove
--turbo from package.json for local development at http://localhost:3000/studio
-
Environment Variables
NEXT_PUBLIC_SANITY_PROJECT_ID=flfshs5n
NEXT_PUBLIC_SANITY_DATASET=production
Markdown Support
npm install sanity-plugin-markdown
npm i markdown-it
npm install --save-dev @types/markdown-it
Type Generation System
-
Extract Schema
npx sanity@latest schema extract --path=./sanity/extract.json
-
Typegen Configuration (sanity-typegen.json)
{
"path": "'../../my-cool-app/src/**/*.{ts,tsx,js,jsx}'",
"schema": "../../my-cool-app/sanity-schemas.json",
"generates": "../../my-cool-app/sanity.types.ts"
}
-
Generate Types
npx sanity@latest typegen generate
Scripts Configuration (package.json)
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint",
"predev": "npm run typegen",
"prebuild": "npm run typegen",
"typegen": "sanity schema extract --path=./sanity/extract.json && sanity typegen generate"
}
Additional Dependencies
-
Server-Side Only
npm i server-only
-
UI Components
npx shadcn@latest add skeleton
npx shadcn@latest add input textarea
npx shadcn@latest add sonner
-
React Fix
npm install react-is
-
Markdown Editor
npm i @uiw/react-md-editor
-
Slug Generation
npm i slugify
Sentry Integration
npx @sentry/wizard@latest -i nextjs --saas --org vnr-3l --project app-name
Key Technologies
- GRPQ Query Language: Used for Sanity data querying
- Type Generation: Automated type safety for Sanity schemas
- Markdown Support: Both in CMS and frontend rendering
Development Workflow
- Run type generation before development/build:
npm run typegen
- Start development server:
npm run dev
This documentation organizes all your setup commands and configurations in a logical flow, making it easier to understand and maintain the project setup.
评论