Docusaurus
Documentation site for Pacing Agency tech stack
Purpose: Documentation site for Pacing Agency tech stack. Provides a browsable, searchable interface for all tool documentation, architecture notes, and operational guides.
Last verified: December 2025
Build test: Verified auto-sync working (December 2025) - tools sync automatically on push to GitHub via prebuild hook.
Account Detailsβ
- Site URL: https://docs.pacing.agency (primary), https://techstackdocs.pages.dev (Cloudflare Pages default)
- GitHub Repository: https://github.com/Pacing-Agency/techstackdocs
- Deployment: Cloudflare Pages (automatic on push to
mainbranch) - Account owner: Ben Power
- Category: DOCUMENTATION
- Account type: INTERNAL
- Authentication: Cloudflare Access with Google OAuth (see Cloudflare Access)
Overviewβ
Docusaurus is a static site generator that transforms our Markdown documentation into a searchable, navigable website. The site automatically syncs all tools/*.md files on every build, making it easy to keep documentation up to date.
Key Features:
- Automatic sync of all
tools/*.mdfiles into browsable docs - Search functionality across all documentation
- Custom Pacing-branded theme matching
pacing.agencyvisual style - Automatic deployment to Cloudflare Pages on Git push
- MDX safety checks (escapes email addresses, handles file links, detects potential secrets)
- Protected access via Cloudflare Access with Google OAuth authentication
Build Processβ
The Docusaurus site is built automatically on every push to the main branch via Cloudflare Pages:
-
Pre-build step:
scripts/sync-tools.cjsruns automatically (viaprebuildhook inpackage.json)- Reads all
tools/*.mdfiles (exceptREADME.md) - Strips existing frontmatter and extracts H1 headings as titles
- Fixes MDX issues (escapes emails, converts file:// links)
- Checks for potential API keys/secrets (logs warnings)
- Writes transformed files to
docs/tools/<tool-name>.md
- Reads all
-
Build step: Docusaurus compiles the site
- Processes all Markdown/MDX files
- Generates static HTML/CSS/JS
- Outputs to
build/directory
-
Deploy step: Cloudflare Pages serves the
build/directory
Local build:
cd docusaurus
npm install
npm run build # Runs sync + build
npm start # Runs sync + dev server
Sync Script Behaviorβ
The docusaurus/scripts/sync-tools.cjs script:
- Source of truth:
tools/*.mdfiles in the parent directory - Output:
docusaurus/docs/tools/*.md(generated, do not edit directly) - Transformations:
- Removes existing frontmatter blocks
- Extracts first H1 heading as page title
- Removes the H1 from body (Docusaurus uses frontmatter title)
- Escapes email addresses:
<email@domain>β<email@domain> - Converts
file://links to inline code blocks - Adds Docusaurus frontmatter with
id,title, andsourcefields
- Safety checks: Warns if JWT-like tokens are detected (doesn't fail build)
- Exclusions: Skips
tools/README.md
Important: Always edit source files in tools/, never edit generated files in docusaurus/docs/tools/ (they get overwritten on every build).
Adding Custom Pagesβ
Option 1: Add a tool doc (auto-synced)β
- Create
tools/<tool-name>.mdin the parent directory - The sync script automatically picks it up on the next build
- It appears in the sidebar under "Tools"
Option 2: Create a custom Docusaurus pageβ
- Create a new file in
docusaurus/docs/(notdocs/tools/) - Add proper frontmatter:
---
id: my-page
title: My Page Title
---
Your content here... - Update
docusaurus/sidebars.tsto include it in navigation if needed
Option 3: Edit core pagesβ
docusaurus/docs/intro.md- Based onREADME.md(manual sync)docusaurus/docs/architecture.md- Based onarchitecture.md(manual sync)docusaurus/docs/tools.md- Tools overview page (edit directly)
Configurationβ
- Config file:
docusaurus/docusaurus.config.ts - Sidebar:
docusaurus/sidebars.ts - Theme: Custom CSS in
docusaurus/src/css/custom.css(matchespacing.agencybrand) - Homepage:
docusaurus/src/pages/index.tsx
Dependenciesβ
- Node.js >= 20.0
- npm (comes with Node.js)
- Dependencies managed in
docusaurus/package.json
MDX Validationβ
The build process includes two layers of MDX validation to catch syntax errors before deployment:
Validation Processβ
The docusaurus/scripts/validate-mdx.cjs script runs automatically as part of the prebuild hook and performs two validation steps:
-
Custom Pattern Checks (Step 1):
- Scans all
.mdand.mdxfiles indocs/ - Checks for common MDX syntax issues:
- Unescaped less-than symbols with numbers (e.g.,
<5%should be{'<5%'}or<5%) - Unescaped email addresses (e.g.,
<email@domain>should be<email@domain>) - Unescaped special characters after
< - Unescaped curly braces in text (for
.mdfiles) - Potential unclosed JSX tags
- Unescaped less-than symbols with numbers (e.g.,
- Provides specific error messages with file, line, and column numbers
- Groups errors by type for easier fixing
- Scans all
-
docusaurus-mdx-checker (Step 2):
- Runs
npx docusaurus-mdx-checkerto validate MDX v3 compatibility - Uses the same MDX parser as Docusaurus v3
- Catches parsing errors that would cause build failures
- Reports which files are incompatible with MDX v3
- Runs
Running Validation Manuallyβ
To run validation manually:
cd docusaurus
node ./scripts/validate-mdx.cjs
This will:
- Run both validation steps
- Report any issues found
- Exit with code 1 if issues are found (blocking build)
- Exit with code 0 if all checks pass
Validation Outputβ
On success:
[validate-mdx] Starting MDX validation...
[validate-mdx] Step 1: Running custom pattern checks...
[validate-mdx] β Custom pattern checks passed.
[validate-mdx] Step 2: Running docusaurus-mdx-checker...
[validate-mdx] β docusaurus-mdx-checker passed.
[validate-mdx] β All MDX validation checks passed.
On failure, the script will:
- Show detailed error messages grouped by type
- Include file paths, line numbers, and column numbers
- Provide specific fix suggestions
- Exit with code 1 to block the build
Integrationβ
- Pre-build hook: Validation runs automatically via
npm run prebuild(called beforenpm run build) - CI/CD: Cloudflare Pages runs validation as part of the build process
- Local development: Run
npm run buildornpm startto trigger validation
Related Toolsβ
- Custom validator:
docusaurus/scripts/validate-mdx.cjs- Pattern-based checks for common issues - docusaurus-mdx-checker: https://github.com/slorber/docusaurus-mdx-checker - Official Docusaurus MDX v3 compatibility checker
- Sync script:
docusaurus/scripts/sync-tools.cjs- Also performs some MDX fixes (email escaping, file link conversion)
Troubleshootingβ
Build fails with MDX errorsβ
- Run
node ./scripts/validate-mdx.cjsmanually to see detailed error messages - Check sync script warnings for potential issues
- Look for unescaped email addresses (
<email@domain>should be<email@domain>) - Check for
file://links that need to be converted - Review docusaurus-mdx-checker output for MDX v3 compatibility issues
- Common fixes:
- Escape less-than symbols:
<5%β{'<5%'}or<5% - Escape email addresses:
<email@domain>β<email@domain> - Escape curly braces in
.mdfiles:{β{'{'}(not needed in.mdxfiles)
- Escape less-than symbols:
Tools not appearing in sidebarβ
- Ensure the file is in
tools/(notdocusaurus/docs/tools/) - Check that the filename matches
*.md(notREADME.md) - Run
npm run prebuildmanually indocusaurus/to see sync output
Cloudflare Pages deploy command error (wrangler deploy)β
- Symptom: Cloudflare build succeeds but deploy fails with
Missing entry-point to Worker script or to assets directoryand logs showExecuting user deploy command: npx wrangler deploy. - Cause: Pages is for static hosting;
wrangler deployexpects a Worker entry point or explicitassets.directory, which we do not configure for this project. - Fix (recommended): In the Cloudflare Pages project:
- Keep Root directory =
docusaurus, Build command =npm run build, Output directory =build. - Set the Deploy command to a simple no-op that always succeeds, for example:
echo "Cloudflare Pages will deploy the docusaurus/build output"
- (Optional) Use the same
echocommand for the nonβproduction branch deploy command. - Do not use
npx wrangler deployfor this static Docusaurus site.
- Keep Root directory =
Changes not showing up locallyβ
- For tools: restart dev server or run
npm run prebuild - For custom pages: changes should hot-reload automatically
Cloudflare Pages Setupβ
The site is deployed via Cloudflare Pages with automatic builds on every push to main.
Current project: techstackdocs1 (connected to Pacing-Agency/techstackdocs)
Initial Setupβ
-
Create Pages project (via Dashboard):
- Go to Cloudflare Dashboard β Workers & Pages β Create application β Pages
- Select "Import an existing Git repository"
- Or create manually and connect Git later
-
Connect GitHub repository (via Dashboard):
- Go to Cloudflare Dashboard β Workers & Pages β
[project-name] - Click "Connect to Git" or "Change source"
- Select GitHub and authorize
- Choose repository:
Pacing-Agency/techstackdocs - Confirm branch:
main
- Go to Cloudflare Dashboard β Workers & Pages β
-
Configure build settings (via Dashboard):
- Framework preset: Docusaurus (auto-fills settings below)
- Production branch:
main - Build command:
npm run build - Build directory:
build - Root directory:
docusaurus
-
Add custom domain (via Dashboard):
- Go to Settings β Custom domains
- Add:
docs.pacing.agency - DNS will be configured automatically
-
Configure Cloudflare Access (if needed):
- Go to Zero Trust β Access β Applications
- Update application to point to the Pages project
- See Cloudflare Access for details
Verified Configuration (December 2025)β
Project: techstackdocs1
- GitHub:
Pacing-Agency/techstackdocs - Branch:
main - Build command:
npm run build - Root directory:
docusaurus - Output directory:
build - Custom domain:
docs.pacing.agency(configured via Dashboard)
Build Configurationβ
| Setting | Value |
|---|---|
| Framework preset | Docusaurus |
| Production branch | main |
| Build command | npm run build |
| Build directory | build |
| Root directory | docusaurus |
The build process automatically:
- Runs
npm run prebuild(syncstools/*.mdfiles) - Runs
npm run build(builds Docusaurus site) - Deploys the
build/directory
Migrating to New Repositoryβ
If the GitHub repository is moved or renamed:
-
Create new Pages project (or update existing):
wrangler pages project create <project-name> --production-branch=main -
Connect new repository via Dashboard (GitHub OAuth required)
-
Update build settings to match configuration above
-
Add custom domain if needed
-
Update Cloudflare Access application to point to new project
-
Delete old project once verified (remove custom domain first)
Related Documentationβ
- Source files:
tools/,architecture.md,README.md - Docusaurus README:
docusaurus/README.md - Sync script:
docusaurus/scripts/sync-tools.cjs - Validation script:
docusaurus/scripts/validate-mdx.cjs - docusaurus-mdx-checker: https://github.com/slorber/docusaurus-mdx-checker
- Cloudflare Pages docs: https://developers.cloudflare.com/pages/framework-guides/deploy-a-docusaurus-site/