Next.js code for docs.silverstripe.org and userhelp.silverstripe.org.
Built with:
- Next.js 16+
- Node.js 24+
- TypeScript
- Markdown (remark/rehype)
- Algolia DocSearch
- Jest + RTL
When creating a new major branch for a pre-release major version
- Make sure you've added a new major branch to both
silverstripe/developer-docsandsilverstripe/silverstripe-userhelp-content - Add the new major to
sources-docs.jsonandsources-user.json - Add the new major branches for various modules as defined in
sources-docs.jsonandsources-user.jsonas well - Update
HIGHEST_VERSIONinglobal-config.tsto the new pre-release major - Add the new major version to the algolia crawler script
For new stable releases, you will need to do the following
- Update
DEFAULT_VERSIONinglobal-config.tsto the new stable major - Update
HIGHEST_VERSIONinglobal-config.tsto matchDEFAULT_VERSION(if it was previously set to a pre-release version) - Update redirects in
netlify.tomlto point to the new stable major
You can develop without clone data using mock data, which is the same mock data used in tests:
npm run mock # Start dev with mock contentFirst, clone documentation content, then start the dev server:
npm run clone:docs # Clone developer docs (or user help with clone:user) - deletes existing data first
npm run dev:docs # Start dev server with cloned developer docs (or user help docs with dev:user)Note that static files are not committed to the repository - they are built during deployment.
# Build and verify locally
npm run build:docs
# Or for user help
npm run build:userTo test the output of npm run build locally:
# Serve the built static site in the out/ directory on port 9877
npm run startnpm install # Install dependencies (use npm install, not npm update)
# Development with mock data (intended for development without clone, uses same mock data as tests)
npm run mock # Dev server with mock data (no cloning needed)
# Clone content
npm run clone # Clone content based on DOCS_CONTEXT (default: docs, alias for clone:docs) - deletes existing data first
npm run clone:docs # Clone developer docs - deletes existing data first
npm run clone:user # Clone user help docs - deletes existing data first
# Development servers (after cloning)
npm run dev # Dev server with developer docs on port 9876 (default: docs context, alias for dev:docs)
npm run dev:docs # Dev server with developer docs on port 9876
npm run dev:user # Dev server with user help on port 9876
# Build static files for deployment
npm run build # Build static files and copy images (default: docs context, alias for build:docs)
npm run build:docs # Build static files and copy images for developer docs
npm run build:user # Build static files and copy images for user help
# Testing
npm test # Run all tests
npm run lint # Run ESLint (must have 0 errors, 0 warnings)
# Utility commands
npm run start # Serve built static files from out/ directory on port 9877
npm run kill # Kill processes running on ports 9876, 9877Create .env.local for local development:
# Algolia DocSearch (optional, search disabled if not set)
# Note that the NEXT_PUBLIC_ prefix is required for Next.js to expose these to the browser
# The NEXT_PUBLIC_DOCSEARCH_API_KEY must be a search-only API key
NEXT_PUBLIC_DOCSEARCH_APP_ID=your_app_id
NEXT_PUBLIC_DOCSEARCH_API_KEY=your_api_key
NEXT_PUBLIC_DOCSEARCH_INDEX_NAME=your_index_nameAdditional environment variables, though these should not be set manually
# Force mock data for testing (automatically set by test runner in setup-tests.js)
NEXT_USE_MOCK_DATA=true
# Manual context switching - used by deployment or npm scripts to control which docs are loaded
DOCS_CONTEXT=docs # or DOCS_CONTEXT=userThis site serves two independent documentation sets:
| Context | Content | Cache Location |
|---|---|---|
docs |
Developer documentation | .cache/docs/ |
user |
End-user help | .cache/user/ |
The DOCS_CONTEXT environment variable controls which documentation set is loaded:
DOCS_CONTEXT=docs- Load developer documentation (default)DOCS_CONTEXT=user- Load end-user help documentation
To switch between docs and user contexts during development:
- Stop the current dev server (Ctrl+C)
- Run the appropriate script:
npm run dev:docs- for developer docsnpm run dev:user- for user help
- The server will start with the correct content
Important: You must stop and restart the dev server when switching contexts. The Next.js cache (.next/) is automatically invalidated when the context changes, but the running process maintains its initial configuration.
If the wrong content appears:
- Stop the dev server completely (Ctrl+C)
- Clear the Next.js cache:
rm -rf .next - Restart with the correct script:
npm run dev:userornpm run dev:docs
The npm scripts wrap commands in sh -c '...' to ensure environment variables are properly inherited by all commands in the chain:
// ❌ Wrong - DOCS_CONTEXT only applies to the first command
"dev:user": "DOCS_CONTEXT=user npm run copy-images:user && next dev"
// ✅ Correct - DOCS_CONTEXT applies to all commands
"dev:user": "DOCS_CONTEXT=user sh -c 'npm run copy-images:user && next dev'"assets/- Source files we want to be exposed (e.g. for favicon and logo). These are copied topublic/andout/.src/- Main source code (React components, pages, lib, types, contexts)scripts/- Node.js scripts for cloning docs and copying imagestests/- Jest tests (mirrorssrc/structure)
.cache/- Cloned documentation content.next/- Next.js build cachepublic/- Static assets for dev server (populated duringnpm run dev)out/- Static HTML export and static assets (populated duringnpm run build)