|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +This is a Docusaurus-based documentation site for [psake](https://github.com/psake/psake), a PowerShell build automation tool. The site uses a hybrid PowerShell/Node.js build system, combining static documentation with auto-generated command references from the psake PowerShell module. |
| 8 | + |
| 9 | +## Build System Architecture |
| 10 | + |
| 11 | +The build system uses **PowerShell + psake** for orchestration, with Docusaurus/Node.js for the site generation: |
| 12 | + |
| 13 | +- **`build.ps1`** - Main entry point that handles bootstrapping and invokes psake tasks |
| 14 | +- **`psakeFile.ps1`** - Task definitions for all build automation |
| 15 | +- **`requirements.psd1`** - PowerShell module dependencies (managed via PSDepend) |
| 16 | + |
| 17 | +### Common Build Commands |
| 18 | + |
| 19 | +```powershell |
| 20 | +# First-time setup (install all dependencies) |
| 21 | +.\build.ps1 -Bootstrap |
| 22 | +
|
| 23 | +# Start development server |
| 24 | +.\build.ps1 -Task Server |
| 25 | +
|
| 26 | +# Full production build |
| 27 | +.\build.ps1 -Task Build |
| 28 | +
|
| 29 | +# Run tests (validates sidebar links) |
| 30 | +.\build.ps1 -Task Test |
| 31 | +
|
| 32 | +# List all available tasks |
| 33 | +.\build.ps1 -Help |
| 34 | +``` |
| 35 | + |
| 36 | +**Important**: The `Server` task runs `yarn serve` which serves the production build. For local development with hot-reload, use: |
| 37 | +```powershell |
| 38 | +.\build.ps1 -Task Init # Install dependencies first |
| 39 | +yarn run start # Then start dev server directly |
| 40 | +``` |
| 41 | + |
| 42 | +### Key Build Tasks |
| 43 | + |
| 44 | +- **Init** - Runs `yarn install` |
| 45 | +- **Build** - Full site build (depends on Init, GenerateCommandReference, FrontMatterCMSSync) |
| 46 | +- **Server** - Serves production build |
| 47 | +- **Test** - Runs Pester tests |
| 48 | +- **GenerateCommandReference** - Auto-generates MDX files for psake commands |
| 49 | +- **FrontMatterCMSSync** - Converts YAML datafiles to JSON for Frontmatter CMS |
| 50 | + |
| 51 | +## Content Architecture |
| 52 | + |
| 53 | +### Command Reference Auto-Generation |
| 54 | + |
| 55 | +Command documentation is **auto-generated** from the psake PowerShell module: |
| 56 | + |
| 57 | +- **Generator**: `New-DocusaurusHelp` from `Alt3.Docusaurus.Powershell` module |
| 58 | +- **Source**: psake module help (from the main psake repository) |
| 59 | +- **Output**: `docs/commands/*.mdx` files |
| 60 | +- **Sidebar**: Auto-imported via `docs/commands/docusaurus.sidebar.js` |
| 61 | +- **Configuration**: See `$docusaurusOptions` in `psakeFile.ps1:12-34` |
| 62 | + |
| 63 | +**Never manually edit files in `docs/commands/`** - they will be overwritten. Edit the source help in the [psake repository](https://github.com/psake/psake) instead. |
| 64 | + |
| 65 | +### Blog Post Management |
| 66 | + |
| 67 | +Blog posts use **YAML datafiles** as the source of truth for authors and tags: |
| 68 | + |
| 69 | +- **Authors**: `blog/authors.yml` (handle as key) |
| 70 | +- **Tags**: `blog/tags.yml` (with label, permalink, description) |
| 71 | +- **Sync**: Run `.\build.ps1 -Task FrontMatterCMSSync` after editing YAML files to regenerate JSON |
| 72 | + |
| 73 | +#### Blog Post Requirements |
| 74 | + |
| 75 | +**File naming**: `YYYY-MM-DD-descriptive-slug.md` |
| 76 | + |
| 77 | +**Required frontmatter**: |
| 78 | +```yaml |
| 79 | +--- |
| 80 | +title: "Clear, descriptive title" |
| 81 | +description: "SEO-friendly description (150-160 chars)" |
| 82 | +date: 2025-08-03T23:38:05.100Z # ISO format |
| 83 | +authors: |
| 84 | + - heyitsgilbert # Handle from blog/authors.yml |
| 85 | +tags: |
| 86 | + - psake # Handles from blog/tags.yml |
| 87 | + - announcement |
| 88 | +--- |
| 89 | +``` |
| 90 | + |
| 91 | +**Content structure**: |
| 92 | +- Engaging intro paragraph |
| 93 | +- `<!-- truncate -->` after first paragraph (for blog list previews) |
| 94 | +- Semantic headings (## for main sections) |
| 95 | + |
| 96 | +**Available tag handles**: `powershell`, `build-automation`, `psake`, `ci-cd`, `testing`, `deployment`, `scripting`, `tutorial`, `getting-started`, `advanced`, `best-practices`, `tips`, `troubleshooting`, `release`, `announcement`, `msbuild`, `dotnet`, `visual-studio` |
| 97 | + |
| 98 | +### Documentation Structure |
| 99 | + |
| 100 | +- **Tutorials**: `docs/tutorial-basics/` and `docs/tutorial-advanced/` |
| 101 | +- **Categories**: Use `_category_.json` files for folder metadata |
| 102 | +- **Sidebar**: Manually maintained in `sidebars.ts` (validated by Pester tests) |
| 103 | + |
| 104 | +## Frontmatter CMS Integration |
| 105 | + |
| 106 | +The site uses Frontmatter CMS for content management: |
| 107 | + |
| 108 | +- **Config**: `frontmatter.json` - defines content types, fields, and datafile mappings |
| 109 | +- **Author/tag dropdowns**: Use `handle` as labelField from datafiles |
| 110 | +- **After YAML changes**: Run `FrontMatterCMSSync` task to update CMS choices |
| 111 | + |
| 112 | +## Testing & Validation |
| 113 | + |
| 114 | +- **Pester tests**: `tests/Docs.Tests.ps1` - validates all docs are linked in sidebar |
| 115 | +- **Build validation**: Docusaurus build fails on broken links (`onBrokenLinks: 'throw'` in config) |
| 116 | +- **Blog validation**: Warns on inline tags/authors, untruncated posts |
| 117 | + |
| 118 | +Run tests before committing: |
| 119 | +```powershell |
| 120 | +.\build.ps1 -Task Test |
| 121 | +``` |
| 122 | + |
| 123 | +## Deployment |
| 124 | + |
| 125 | +- **Platform**: Netlify (auto-deploy from `main` branch) |
| 126 | +- **Build output**: `/build` directory (static site) |
| 127 | +- **Preview URL**: Local server runs on http://localhost:3000 |
| 128 | + |
| 129 | +## Key Conventions |
| 130 | + |
| 131 | +1. **All docs must be linked in `sidebars.ts`** - Pester tests enforce this |
| 132 | +2. **YAML files are source of truth** - JSON files are generated, don't edit them |
| 133 | +3. **Command docs are auto-generated** - Edit source help in psake repo, not MDX files |
| 134 | +4. **Blog posts require frontmatter validation** - Missing required fields will cause warnings |
| 135 | + |
| 136 | +## Dependencies |
| 137 | + |
| 138 | +- **Node.js**: >=18.0 (specified in package.json engines) |
| 139 | +- **PowerShell**: 7+ (required by psakeFile.ps1) |
| 140 | +- **Package manager**: Yarn (locked version via packageManager field) |
| 141 | +- **PowerShell modules**: Auto-installed via PSDepend during bootstrap |
| 142 | + |
| 143 | +## Adding New Content |
| 144 | + |
| 145 | +### New Blog Post Checklist |
| 146 | +1. Use `YYYY-MM-DD-slug.md` naming |
| 147 | +2. Add required frontmatter (title, description, date, authors, tags) |
| 148 | +3. Verify author handle exists in `blog/authors.yml` |
| 149 | +4. Verify tag handles exist in `blog/tags.yml` |
| 150 | +5. Include intro + `<!-- truncate -->` + main content |
| 151 | +6. Run `.\build.ps1 -Task Test` to validate |
| 152 | +7. Preview with `yarn run start` |
| 153 | + |
| 154 | +### New Author or Tag |
| 155 | +1. Add to `blog/authors.yml` or `blog/tags.yml` |
| 156 | +2. Run `.\build.ps1 -Task FrontMatterCMSSync` |
| 157 | + |
| 158 | +### New Documentation Page |
| 159 | +1. Add markdown file to appropriate `docs/` subdirectory |
| 160 | +2. Update `sidebars.ts` to include the new page |
| 161 | +3. Run `.\build.ps1 -Task Test` to ensure it's properly linked |
0 commit comments