|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +Hinode is a Hugo theme for documentation and blog sites built on Bootstrap 5. It uses Hugo's module system to manage dependencies and includes Bookshop for component-based development. The theme is designed for performance, security (with CSP headers), and SEO. |
| 8 | + |
| 9 | +## Common Development Commands |
| 10 | + |
| 11 | +### Development Server |
| 12 | + |
| 13 | +```bash |
| 14 | +npm start # Start Hugo server with module vendoring |
| 15 | +npm run start:example # Start server using exampleSite |
| 16 | +npm run start:prod # Start server in production mode |
| 17 | +npm run start:example:prod # Start exampleSite in production mode |
| 18 | +``` |
| 19 | + |
| 20 | +### Building |
| 21 | + |
| 22 | +```bash |
| 23 | +npm run build # Build site with minification |
| 24 | +npm run build:example # Build exampleSite |
| 25 | +npm run build:debug # Build with debug output |
| 26 | +npm run build:headers # Generate Netlify/server headers |
| 27 | +``` |
| 28 | + |
| 29 | +### Linting & Testing |
| 30 | + |
| 31 | +```bash |
| 32 | +npm test # Run all linters |
| 33 | +npm run lint # Run all linters |
| 34 | +npm run lint:scripts # ESLint for JavaScript (assets/js) |
| 35 | +npm run lint:styles # Stylelint for SCSS |
| 36 | +npm run lint:markdown # Markdownlint for Markdown files |
| 37 | +``` |
| 38 | + |
| 39 | +### Module Management |
| 40 | + |
| 41 | +```bash |
| 42 | +npm run mod:vendor # Vendor Hugo modules to _vendor/ |
| 43 | +npm run mod:update # Update all Hugo modules |
| 44 | +npm run mod:tidy # Clean up unused module dependencies |
| 45 | +npm run mod:clean # Remove module cache |
| 46 | +``` |
| 47 | + |
| 48 | +### Maintenance |
| 49 | + |
| 50 | +```bash |
| 51 | +npm run clean:public # Remove generated public/ directories |
| 52 | +npm run clean:install # Remove node_modules and package-lock.json |
| 53 | +npm run upgrade # Update npm and Hugo module dependencies |
| 54 | +``` |
| 55 | + |
| 56 | +## Architecture |
| 57 | + |
| 58 | +### Hugo Module System |
| 59 | + |
| 60 | +The theme uses Hugo's module system extensively. All modules are vendored to `_vendor/` for reproducible builds. Key modules include: |
| 61 | + |
| 62 | +- `mod-bootstrap` - Bootstrap 5 framework |
| 63 | +- `mod-flexsearch` - Full-text search functionality |
| 64 | +- `mod-fontawesome` - Icon support |
| 65 | +- `mod-utils` - Utility functions and helpers |
| 66 | +- `mod-katex`, `mod-mermaid`, `mod-leaflet`, `mod-lottie` - Optional feature modules |
| 67 | +- `cloudcannon/bookshop` - Component library system |
| 68 | + |
| 69 | +Module configuration is in `config/_default/hugo.toml` under `[module.imports]`. Always run `npm run mod:vendor` after module changes. |
| 70 | + |
| 71 | +### Component Library (Bookshop) |
| 72 | + |
| 73 | +Components live in `component-library/components/`. Each component has: |
| 74 | + |
| 75 | +- `*.hugo.html` - Hugo template |
| 76 | +- `*.scss` - Component styles |
| 77 | +- `*.bookshop.yml` - Schema definition |
| 78 | + |
| 79 | +Components are mounted to multiple locations via `hugo.toml`: |
| 80 | + |
| 81 | +- `layouts/partials/bookshop/` - Templates |
| 82 | +- `data/structures/` - Schemas |
| 83 | +- `assets/scss/modules/bookshop/` - Styles |
| 84 | + |
| 85 | +### Directory Structure |
| 86 | + |
| 87 | +- `layouts/` - Theme templates and shortcodes |
| 88 | + - `baseof.html` - Base template with navbar, footer, and content blocks |
| 89 | + - `_partials/` - Reusable template components |
| 90 | + - `_shortcodes/` - Hugo shortcodes for content (accordion, alert, card, etc.) |
| 91 | +- `assets/` - Source assets (JS, SCSS, images, icons) |
| 92 | + - `scss/` - Organized into components/, layouts/, theme/, helpers/ |
| 93 | + - `js/` - JavaScript modules |
| 94 | +- `config/` - Hugo configuration |
| 95 | + - `_default/hugo.toml` - Main config with module imports |
| 96 | + - `postcss.config.js` - PostCSS with PurgeCSS and autoprefixer |
| 97 | +- `content/` - Theme content (minimal, main content in exampleSite) |
| 98 | +- `data/` - Data files for theme configuration |
| 99 | +- `i18n/` - Translation files (en, nl, fr, de, pl, pt-br, zh-hans, zh-hant) |
| 100 | +- `exampleSite/` - Full example site for testing theme |
| 101 | +- `static/` - Static assets copied directly to output |
| 102 | + |
| 103 | +### CSS Pipeline |
| 104 | + |
| 105 | +CSS uses PostCSS with: |
| 106 | + |
| 107 | +1. **Autoprefixer** - Adds vendor prefixes |
| 108 | +2. **cssnano** - Minification |
| 109 | +3. **PurgeCSS** - Removes unused CSS based on `hugo_stats.json` |
| 110 | + |
| 111 | +PurgeCSS safelist is defined in `config/postcss.config.js`. When adding new dynamic classes or Bootstrap components, update the safelist to prevent removal. |
| 112 | + |
| 113 | +### Version Management |
| 114 | + |
| 115 | +The theme supports versioned documentation with sidebar menus per version. Version detection happens in `baseof.html` using `utilities/GetVersion.html` partial. |
| 116 | + |
| 117 | +### Shortcodes System |
| 118 | + |
| 119 | +Extensive shortcode library in `layouts/_shortcodes/` provides Bootstrap components accessible in Markdown: |
| 120 | + |
| 121 | +- Layout: accordion, card, carousel, collapse, navbar, tabs |
| 122 | +- UI: alert, badge, button, spinner, toast, tooltip |
| 123 | +- Content: image, video, table, timeline |
| 124 | +- Typography: abbr, kbd, mark, sub, sup |
| 125 | + |
| 126 | +### Content Security Policy |
| 127 | + |
| 128 | +CSP headers are auto-generated via Hugo's segments feature. The theme includes `mod-csp` for Content Security Policy management. Headers are defined in `netlify.toml` and generated via `npm run build:headers`. |
| 129 | + |
| 130 | +### Internationalization |
| 131 | + |
| 132 | +Multi-language support with translations in `i18n/`. Default language is English (`en-us`). Language configuration in `config/_default/hugo.toml`. |
| 133 | + |
| 134 | +## Key Configuration Files |
| 135 | + |
| 136 | +- `hugo.toml` - Main Hugo config with modules, mounts, build settings |
| 137 | +- `package.json` - npm scripts and dependencies |
| 138 | +- `go.mod` - Hugo module dependencies (Go modules) |
| 139 | +- `postcss.config.js` - PostCSS pipeline with PurgeCSS safelist |
| 140 | +- `netlify.toml` - Netlify build config and security headers |
| 141 | +- `.eslintrc.yml` - JavaScript linting (ES6, browser environment) |
| 142 | +- `.stylelintrc.json` - SCSS linting (standard-scss) |
| 143 | +- `.markdownlint-cli2.jsonc` - Markdown linting rules |
| 144 | + |
| 145 | +## Important Development Notes |
| 146 | + |
| 147 | +### When Modifying Components |
| 148 | + |
| 149 | +1. Components in `component-library/` need three files: `.hugo.html`, `.scss`, `.bookshop.yml` |
| 150 | +2. Update PurgeCSS safelist in `config/postcss.config.js` if adding dynamic classes |
| 151 | +3. Component styles are automatically mounted via `hugo.toml` module mounts |
| 152 | + |
| 153 | +### When Adding Hugo Modules |
| 154 | + |
| 155 | +1. Add to `go.mod` requires section |
| 156 | +2. Add to `[module.imports]` in `hugo.toml` |
| 157 | +3. Run `npm run mod:vendor` to vendor the module |
| 158 | +4. If module has styles, add to PurgeCSS safelist in `postcss.config.js` |
| 159 | + |
| 160 | +### When Working with Layouts |
| 161 | + |
| 162 | +- `baseof.html` is the main template; it sets up version-aware menus, content blocks, overlay mode |
| 163 | +- Partials in `_partials/` are organized: `head/`, `footer/`, `page/`, `utilities/`, `assets/` |
| 164 | +- The theme uses `.Scratch` extensively for passing data between partials |
| 165 | + |
| 166 | +### Build Process |
| 167 | + |
| 168 | +1. `hugo mod vendor` - Vendors modules to `_vendor/` |
| 169 | +2. Hugo build generates `hugo_stats.json` with used classes/tags/ids |
| 170 | +3. PostCSS processes SCSS, using `hugo_stats.json` to purge unused CSS |
| 171 | +4. Final output in `public/` or `exampleSite/public/` |
| 172 | + |
| 173 | +### Testing Changes |
| 174 | + |
| 175 | +Test with both main site and exampleSite: |
| 176 | + |
| 177 | +- `npm start` - Test theme directly |
| 178 | +- `npm run start:example` - Test with full example content |
| 179 | +- `npm run lint` - Check code quality before committing |
| 180 | + |
| 181 | +### Git Workflow |
| 182 | + |
| 183 | +- Main branch: `main` (production releases) |
| 184 | +- Development branch: `develop` |
| 185 | +- Uses semantic-release for automated versioning |
| 186 | +- Commits follow conventional commits (enforced by commitlint) |
| 187 | +- Husky pre-commit hooks run linters |
0 commit comments