@@ -100,24 +100,27 @@ Based on comprehensive PR review analysis, follow these critical development sta
100100- Use utilities from established libraries: 'web-utility'
101101- Import ` './Base' ` in model files for proper configuration
102102
103- ### UI/UX Standards
103+ #### Data and API Integration
104104
105- #### Component Usage Patterns
105+ - Use ** GitHub API** with ContentModel from mobx-github for content management
106+ - Use configured ` githubClient ` from ` models/Base.ts ` for authenticated API calls
107+ - ** Base64 decode** content from GitHub API responses: ` atob(item.content) `
108+ - Replace filesystem reading with GitHub Contents API calls
109+ - Use ` ContentModel('owner', 'repo') ` pattern for repository content access
106110
107- ``` typescript
108- // ✅ Correct - use React Bootstrap components
109- import { Button , Badge , Breadcrumb , Card , Container } from ' react-bootstrap' ;
111+ #### Error Handling and Static Generation
110112
111- < Button variant = " outline-primary " size = " sm " href = { url } target = " _blank " >
112- { t ( ' edit_on_github ' )}
113- < / Button >
113+ - ** Natural error throwing ** for static generation - let errors bubble up to catch build issues
114+ - Don't catch errors in ` getStaticProps ` unless specifically handling them
115+ - Ensure build passes before pushing - resolve issues at compile time
114116
115- < Badge bg = " secondary " > { label } < / Badge >
117+ ### UI/UX Standards
116118
117- // ❌ Wrong - custom HTML elements
118- < a href = {url } className = " btn btn-outline-primary" > Edit < / a >
119- < span className = " badge bg-secondary" > {label }< / span >
120- ```
119+ #### Component Usage Patterns
120+
121+ - ** ALWAYS use React Bootstrap components** instead of custom HTML elements
122+ - Use utilities from established libraries: 'web-utility'
123+ - Import from existing configured clients: use ` githubClient ` from ` models/Base.ts `
121124
122125#### Semantic HTML Structure
123126
@@ -129,34 +132,16 @@ import { Button, Badge, Breadcrumb, Card, Container } from 'react-bootstrap';
129132
130133#### Modern ECMAScript Features
131134
132- ``` typescript
133- // ✅ Correct - use optional chaining
134- node .parent_path ?.split (' /' )
135- node .children ?.length > 0
136-
137- // ✅ Correct - let TypeScript infer types when possible
138- const renderTree = (nodes : WikiNode [], level = 0 ) => (
139- // No need for explicit return type annotation
140- )
141-
142- // ❌ Wrong - verbose type annotations where inference works
143- const renderTree = (nodes : WikiNode [], level = 0 ): React .ReactElement => (
144- ` ` `
135+ - Use optional chaining and modern JavaScript features
136+ - Let TypeScript infer types when possible to avoid verbose annotations
137+ - Use modern ECMAScript patterns for cleaner, more maintainable code
145138
146139#### Import and Type Management
147140
148- ` ` ` typescript
149- // ✅ Correct - import from established sources
150- import { ContentModel } from ' mobx-github' ;
151- import { treeFrom } from ' web-utility' ;
152- import ' ./Base' ; // For configuration
153-
154- // ✅ Correct - minimal exports
155- export const policyContentStore = new ContentModel (' fpsig' , ' open-source-policy' );
156-
157- // ❌ Wrong - unnecessary custom implementations
158- // Don't create new GitHub API clients when configured ones exist
159- ` ` `
141+ - Import from established sources: ContentModel from mobx-github, utilities from web-utility
142+ - Import configuration files where needed: ` './Base' ` for GitHub client setup
143+ - Use minimal exports and avoid unnecessary custom implementations
144+ - Use configured clients rather than creating new ones
160145
161146### Translation and Internationalization
162147
@@ -168,19 +153,9 @@ export const policyContentStore = new ContentModel('fpsig', 'open-source-policy'
168153
169154#### Translation Patterns
170155
171- ` ` ` typescript
172- // ✅ Correct - all text translated
173- const { t } = useContext (I18nContext );
174-
175- <p >{t(' no_docs_available' )}< / p >
176- <Button >{t(' contribute_content' )}< / Button >
177- alert (t (' operation_successful' ));
178-
179- // ❌ Wrong - hardcoded text
180- <p >暂无政策文档< / p >
181- <Button >贡献内容< / Button >
182- alert (' 操作成功' );
183- ` ` `
156+ - Use the ` t() ` function from I18nContext for all user-facing text
157+ - Translate all button text, labels, error messages, and dynamic content
158+ - Avoid hardcoded text in any language
184159
185160#### Translation Key Management
186161
@@ -192,25 +167,14 @@ alert('操作成功');
192167
193168#### Content Model Patterns
194169
195- ` ` ` typescript
196- // ✅ Correct - use ContentModel with configured client
197- import { ContentModel } from ' mobx-github' ;
198- import ' ./Base' ; // Ensures githubClient configuration
199-
200- export const policyContentStore = new ContentModel (' fpsig' , ' open-source-policy' );
201-
202- // Content processing with proper Base64 decoding
203- const content = item .content ? atob (item .content ) : ' ' ;
204- ` ` `
170+ - Use ContentModel with configured client from mobx-github
171+ - Import configuration via ` './Base' ` to ensure proper GitHub client setup
172+ - Handle Base64 content decoding when processing GitHub API responses
205173
206174#### Tree Structure and Navigation
207175
208- ` ` ` typescript
209- // ✅ Correct - use treeFrom utility for hierarchical data
210- import { treeFrom } from ' web-utility' ;
211-
212- const tree = treeFrom (nodes , ' path' , ' parent_path' , ' children' );
213- ` ` `
176+ - Use ` treeFrom ` utility from web-utility for hierarchical data structures
177+ - Follow established patterns for tree node organization and navigation
214178
215179### GitHub Integration Standards
216180
0 commit comments