A Next.js-based website powered by LeadCMS with support for multiple languages and static site generation.
- Node.js 20+
- pnpm (install with
npm install -g pnpm) - Docker (optional, for containerized deployment)
-
Clone the repository
git clone git@github.com:LeadCMS/leadcms.ai.next.git cd leadcms.ai.next -
Install dependencies
pnpm install
-
Configure environment variables
cp .env.sample .env
Edit
.envand configure the following variables:# LeadCMS Configuration NEXT_PUBLIC_LEADCMS_URL=https://admin.leadcms.ai # LeadCMS API Key (keep this private - no NEXT_PUBLIC_ prefix) LEADCMS_API_KEY=[Your LeadCMS API Key] # Default language for content NEXT_PUBLIC_LEADCMS_DEFAULT_LANGUAGE=en # Development Mode Configuration NEXT_PUBLIC_DEV_MODE=false
Start the development server:
pnpm run devThis command will:
- Fetch content from LeadCMS (
pnpm run fetch) - Generate environment JavaScript file (
pnpm run generate:env) - Start the Next.js development server on
http://localhost:3000
The site supports multiple languages with the following URL structure:
- English (default):
http://localhost:3000/ - Danish:
http://localhost:3000/da/ - Russian:
http://localhost:3000/ru/ - Sinhala:
http://localhost:3000/si/
- Hot reloading: Changes to code are automatically reflected
- Content sync: LeadCMS content is fetched automatically before starting
- Multi-language support: Navigate between different language versions
- MDX support: Full MDX component support for rich content
Create a production build:
pnpm run buildThis will:
- Fetch the latest content from LeadCMS
- Generate static files optimized for production
- Create an
out/directory with the static site
Serve the production build locally:
pnpm run serveThis uses pnpm dlx serve which downloads and runs the serve package to serve the static files from the out/ directory on http://localhost:3000.
Note:
pnpm dlxis equivalent tonpx- it downloads and executes a package without permanently installing it.
Build and run the production Docker container:
# Build the production image
pnpm run docker:build
# Run the production container
pnpm run docker:runThe site will be available at http://localhost:3000.
For development and preview purposes, you can run the site in preview mode which includes:
- Live content updates from LeadCMS
- Server-side rendering
- Real-time content synchronization
# Build the preview image
pnpm run docker:preview:build
# Run the preview container
pnpm run docker:preview:runThe preview mode includes:
- nginx reverse proxy on port 80
- Next.js server on internal port 3000
- SSE watcher for live LeadCMS content updates
- Supervisor managing all services
| Script | Description |
|---|---|
pnpm run dev |
Start development server with content fetch |
pnpm run build |
Build for production |
pnpm run start |
Start production server |
pnpm run serve |
Serve static build locally (uses pnpm dlx) |
pnpm run fetch |
Manually fetch LeadCMS content |
pnpm run generate:env |
Generate environment JavaScript file |
pnpm run docker:build |
Build production Docker image |
pnpm run docker:run |
Run production Docker container |
pnpm run docker:preview:build |
Build preview Docker image |
pnpm run docker:preview:run |
Run preview Docker container |
pnpm run format |
Format code with Prettier |
pnpm run lint |
Run ESLint |
The site supports multiple languages:
- English (default): Content stored in
.leadcms/content/ - Other languages: Content stored in
.leadcms/content/{language}/
- Add the language route in
app/{language}/ - Configure the language in your LeadCMS instance
- Content will be automatically fetched and organized by language
Content is managed through LeadCMS and automatically synchronized:
- Content Fetching: Run
pnpm run fetchto pull latest content - Auto-sync: Content is fetched automatically before builds
- Live Updates: Preview mode supports real-time content updates via Server-Sent Events
Use preview mode for:
- Staging environments
- Live content preview
- Development with real-time updates
- Missing environment variables: Ensure
.envis properly configured - Content not loading: Check LeadCMS API key and URL
- Build failures: Run
pnpm run fetchmanually to debug content issues - Docker issues: Ensure environment variables are passed to containers
- Fork the repository
- Create a feature branch
- Make your changes
- Test locally with
pnpm run dev - Build and test with
pnpm run build - Submit a pull request