GitHub Copilot Instructions for Documentation Site (docsite) Folder
Overview
This folder contains a Docusaurus-based documentation site for the Reports application. The site is built with Docusaurus 3.8.1 and deployed to Cloudflare Pages.
Technology Stack
- Docusaurus: 3.8.1
- Node.js: 22.x (specified in package.json engines)
- React: 19.0.0
- TypeScript: ~5.6.2
- Search: docusaurus-lunr-search
- Deployment: Cloudflare Pages via Wrangler
Setup Instructions
Prerequisites
- Install Node.js 22.x:
# Using nvm (recommended)
nvm install 22
nvm use 22
# Or download from https://nodejs.org/
- The project uses npm (not yarn) for dependency management
Development Setup
cd docsite
# Install dependencies
npm ci
# Start development server
npm start
# The site will be available at http://localhost:3000
Building
cd docsite
# Build the static site
npm run build
# The output will be in the `build` directory
# Serve the built site locally
npm run serve
File Structure
- docs/ - Markdown documentation files
- src/ - Custom React components and pages
- static/ - Static assets (images, files)
- docusaurus.config.ts - Main Docusaurus configuration
- sidebars.ts - Sidebar configuration
- package.json - Dependencies and scripts
- tsconfig.json - TypeScript configuration
- wrangler.jsonc - Cloudflare Pages deployment configuration
Important Notes
Symlinks Don't Work
Docusaurus does not support symlinks in the docs folder. If you need to include content from other parts of the repository:
- Copy the file instead of symlinking
- Use the CI/CD pipeline to copy files during build (see
.github/workflows/docsite.yml) - Use a pre-build script to copy files if needed
PostCSS Conflict
The parent directory contains a postcss.config.js file that conflicts with Docusaurus's PostCSS configuration. The CI workflow removes this file before building:
- name: Remove postcss.config.js
run: rm -f ../postcss.config.js
This is necessary for the build to succeed.
Development Workflow
Adding Documentation
- Create a new
.mdfile in thedocs/directory - Add frontmatter if needed:
---
sidebar_position: 1
---
# Your Title Here
- The sidebar is auto-generated from the file structure (see
sidebars.ts) - Test locally with
npm start
Including External Content
Since symlinks don't work, use a build-time copy:
- Add a step to
.github/workflows/docsite.ymlbefore the build:
- name: Copy external documentation
run: |
cp ../.github/instructions/terraform.instructions.md docs/infra-setup.md
- Ensure the copied file has proper frontmatter for Docusaurus
- Add the file to
.gitignoreif it's only generated during build
Styling and Components
- Custom CSS: Add to
src/css/custom.css - Custom React components: Add to
src/components/ - Custom pages: Add to
src/pages/
Search Configuration
The site uses docusaurus-lunr-search for client-side search. It automatically indexes all documentation pages.
CI/CD Integration
GitHub Actions Workflow
The .github/workflows/docsite.yml workflow:
- Checks out the code
- Sets up Node.js 22.x (using node-version-file from package.json)
- Removes the parent
postcss.config.jsfile - Installs dependencies with
npm ci - Builds the site with
npm run build - Deploys to Cloudflare Pages
Deployment
The site is automatically deployed to Cloudflare Pages on:
- Push to
mainbranch (when docsite files change) - Pull requests (when docsite files change)
Deployment requires:
CLOUDFLARE_ACCOUNT_TOKENsecretCLOUDFLARE_ACCOUNT_IDsecret
Common Tasks
Updating Dependencies
cd docsite
# Update all dependencies
npm update
# Update specific package
npm update @docusaurus/core
# Check for outdated packages
npm outdated
Clearing Cache
cd docsite
# Clear Docusaurus cache
npm run clear
Type Checking
cd docsite
# Run TypeScript type checker
npm run typecheck
Adding a New Plugin
- Install the plugin:
npm install --save docusaurus-plugin-name
- Add to
docusaurus.config.ts:
plugins: [
'docusaurus-plugin-name',
],
Troubleshooting
Build Fails with PostCSS Error
Solution: Ensure the parent postcss.config.js is removed before building (done automatically in CI)
Symlink Errors
Solution: Replace symlinks with actual files or copy during build
Node Version Mismatch
Solution: Use Node 22.x as specified in package.json engines field
Module Not Found Errors
Solution:
rm -rf node_modules package-lock.json
npm install
TypeScript Errors
Solution: Check tsconfig.json and ensure all necessary type definitions are installed
Best Practices
- Always test locally before committing documentation changes
- Use descriptive file names for documentation files
- Add frontmatter to control sidebar position and labels
- Optimize images before adding to
static/folder - Keep dependencies updated but test thoroughly
- Use semantic versioning for the docsite package.json
- Write clear, concise documentation with examples
- Use code blocks with language syntax highlighting
- Link to related documentation for better navigation
- Test builds in CI before merging
Resources
- Docusaurus Documentation: https://docusaurus.io/docs
- Markdown Guide: https://www.markdownguide.org/
- React Documentation: https://react.dev/
- TypeScript Documentation: https://www.typescriptlang.org/docs/
- Cloudflare Pages: https://developers.cloudflare.com/pages/
When Working with Documentation
- Test First: Always run
npm startto preview changes - Check Links: Ensure all internal links work correctly
- Format Code: Use proper syntax highlighting in code blocks
- Structure Content: Use headings, lists, and sections appropriately
- Include Examples: Provide code examples where helpful
- Keep It Updated: Update documentation when code changes
- Follow Style: Match the existing documentation style
- Build Locally: Run
npm run buildbefore committing to catch errors