|
| 1 | +# Agent Guidelines for Luogu Docs |
| 2 | + |
| 3 | +## Build and Development Commands |
| 4 | + |
| 5 | +### Development |
| 6 | +- `pnpm install` - Install dependencies |
| 7 | +- `pnpm run start` - Start development server (localhost:3000) |
| 8 | +- `pnpm run start -h 0.0.0.0` - Start with external access for GitHub Codespaces |
| 9 | +- `pnpm run serve` - Serve built site locally |
| 10 | +- `pnpm run clear` - Clear Docusaurus cache |
| 11 | + |
| 12 | +### Build and Testing |
| 13 | +- `pnpm run build` - Build production version |
| 14 | +- `pnpm run typecheck` - Run TypeScript type checking |
| 15 | + |
| 16 | +### Documentation |
| 17 | +- `pnpm run write-translations` - Generate translation files |
| 18 | +- `pnpm run write-heading-ids` - Generate heading IDs for MDX |
| 19 | + |
| 20 | +## Project Structure |
| 21 | + |
| 22 | +``` |
| 23 | +docs/ |
| 24 | +├── docs/ |
| 25 | +│ ├── manual/ |
| 26 | +│ │ ├── class/ # Luogu class and paid services docs |
| 27 | +│ │ ├── luogu/ # Main site operation guide |
| 28 | +│ │ │ ├── account/ # Account management |
| 29 | +│ │ │ ├── problem/ # Problem-related guides |
| 30 | +│ │ │ └── team/ # Team and group features |
| 31 | +│ │ └── _image/ # Images for manual docs |
| 32 | +│ ├── rules/ |
| 33 | +│ │ ├── community/ # Community rules |
| 34 | +│ │ └── academic/ # Academic guidelines |
| 35 | +│ │ ├── guide/ # Academic guides |
| 36 | +│ │ ├── handbook/ # Academic handbook |
| 37 | +│ │ └── lgr/ # Luogu official contests guidelines |
| 38 | +│ │ └── _image/ # Images for rules docs |
| 39 | +│ └── ula/ # User License Agreements |
| 40 | +├── src/ |
| 41 | +│ ├── pages/ # Custom pages (about, contact, etc.) |
| 42 | +│ └── style.css # Custom theme styles |
| 43 | +└── static/img/ # Static images |
| 44 | +
|
| 45 | +Docusaurus Configuration |
| 46 | +├── docusaurus.config.ts # Main configuration |
| 47 | +├── sidebars.ts # Sidebar structure |
| 48 | +├── tsconfig.json # TypeScript config |
| 49 | +└── babel.config.js # Babel configuration |
| 50 | +``` |
| 51 | + |
| 52 | +## Code Style Guidelines |
| 53 | + |
| 54 | +### Documentation Content (Markdown/MDX) |
| 55 | + |
| 56 | +**Frontmatter Format:** |
| 57 | +```markdown |
| 58 | +--- |
| 59 | +sidebar_position: 1 |
| 60 | +--- |
| 61 | +``` |
| 62 | + |
| 63 | +- Use Chinese language for all content (zh-Hans) |
| 64 | +- Use `sidebar_position` to control documentation order in sidebar |
| 65 | +- Maintain consistent heading levels (use H1 for page titles, H2-H4 for sections) |
| 66 | +- Use bullet points and numbered lists for clarity |
| 67 | +- Include images in `docs/*/` or `docs/*/_image/` directories with descriptive filenames |
| 68 | + |
| 69 | +**Content Structure:** |
| 70 | +- Start with a brief introduction if applicable |
| 71 | +- Use subheadings for main sections |
| 72 | +- Provide clear step-by-step instructions for guides |
| 73 | +- Include warnings, notes, and important information using standard markdown |
| 74 | + |
| 75 | +### TypeScript Configuration |
| 76 | + |
| 77 | +- Extends Docusaurus default TypeScript configuration |
| 78 | +- Compiler options in `tsconfig.json` |
| 79 | +- Use type checking before commits (`pnpm run typecheck`) |
| 80 | + |
| 81 | +### Babel Configuration |
| 82 | + |
| 83 | +- Use Docusaurus preset as default |
| 84 | +- No additional plugins configured |
| 85 | + |
| 86 | +## Naming Conventions |
| 87 | + |
| 88 | +**Documentation:** |
| 89 | +- Use descriptive filenames in lowercase with hyphens: `image-hosting.md` |
| 90 | +- Use snake_case for image directories: `_image/` |
| 91 | +- Page titles use H1 heading |
| 92 | + |
| 93 | +**Image Files:** |
| 94 | +- Use descriptive names with underscores: `TrainingList1.jpg` |
| 95 | +- Include sequence numbers for multi-step guides |
| 96 | + |
| 97 | +**Code Blocks:** |
| 98 | +- Specify language for syntax highlighting: ````markdown, ````typescript, ````bash, etc. |
| 99 | + |
| 100 | +## Writing Guidelines |
| 101 | + |
| 102 | +### Tone and Style |
| 103 | +- Use clear, concise, and professional Chinese language |
| 104 | +- Be instructional and user-friendly |
| 105 | +- Avoid unnecessary technical jargon or explain it when used |
| 106 | +- Maintain consistency in terminology across documents |
| 107 | + |
| 108 | +### Structure |
| 109 | +1. **Introduction**: Brief overview of what the page covers |
| 110 | +2. **Key Sections**: Organized with clear headings |
| 111 | +3. **Examples**: Include screenshots where appropriate (in `_image` directories) |
| 112 | +4. **Related Links**: Reference other relevant documentation |
| 113 | +5. **Contact Info**: Provide contact/support information when needed |
| 114 | + |
| 115 | +### Best Practices |
| 116 | +- Keep content up-to-date with the actual website functionality |
| 117 | +- Use the `release-note.md` page for major changes |
| 118 | +- Include relative image paths: `` |
| 119 | +- Update `sidebars.ts` when adding new documentation sections |
| 120 | +- Test that links work correctly |
| 121 | +- Use Docusaurus features like admonitions when appropriate |
| 122 | + |
| 123 | +## Testing and Validation |
| 124 | + |
| 125 | +Before committing changes: |
| 126 | +1. Run `pnpm run typecheck` to verify TypeScript types |
| 127 | +2. Run `pnpm run build` to ensure production build succeeds |
| 128 | +3. Check for broken links in markdown files |
| 129 | +4. Verify image paths are correct |
| 130 | +5. Test documentation navigation in development mode |
| 131 | +6. Ensure all internal links use relative paths starting with `/` |
| 132 | + |
| 133 | +## Git Commit Guidelines |
| 134 | + |
| 135 | +- Write commit messages in Chinese |
| 136 | +- Be descriptive about what was changed |
| 137 | +- Include relevant context in the message |
| 138 | +- Examples: |
| 139 | + - "更新洛谷题单功能说明" |
| 140 | + - "添加学术规范新章节" |
| 141 | + - "修复图片路径错误" |
| 142 | + |
| 143 | +## Additional Notes |
| 144 | + |
| 145 | +- Project uses Docusaurus 3.6.1 |
| 146 | +- Package manager: pnpm (recommended) |
| 147 | +- Node.js version: >=20.17 |
| 148 | +- Math/TeX support via remarkMath and rehypeKatex |
| 149 | +- Search functionality via @easyops-cn/docusaurus-search-local |
| 150 | +- No linting or formatting configuration (uses editor defaults) |
0 commit comments