Open Source Bazaar 是一个基于 Next.js 15、TypeScript、React Bootstrap 和 MobX 构建的开源项目展示平台。它包含许可证过滤器、Wiki 知识库、志愿者展示、Lark 集成等功能。
Always reference these instructions first and fallback to search or bash commands only when you encounter unexpected information that does not match the info here.
- Check Node.js version:
node --version - Development and linting commands work on Node.js 20+
- Use PNPM as package manager, not npm or yarn
- Install global pnpm:
npm install -g pnpm - Install dependencies:
pnpm install-- takes 1-3 minutes. NEVER CANCEL. Set timeout to 5+ minutes. - Verify setup:
pnpm --version(should be 10.x+)
Important: If you see "node_modules missing" error, you MUST run pnpm install first before any other commands.
- Start development server:
pnpm dev-- starts in 5-15 seconds on http://localhost:3000 - Run linting:
pnpm lint-- takes 15 seconds. NEVER CANCEL. Set timeout to 2+ minutes. - Run tests:
pnpm test-- runs lint-staged + lint, takes 15 seconds. Set timeout to 2+ minutes.
- Production build:
pnpm build-- works on Node.js 20+ (estimated 30s-2 minutes)- NEVER CANCEL. Set timeout to 5+ minutes.
- Static export: Available but not commonly used in development
After making ANY changes, ALWAYS validate by running through these scenarios:
- Start development server:
pnpm devand verify it starts without errors - Navigate to homepage: Visit http://localhost:3000 and verify page loads with navigation menu
- Test core pages:
- License filter: http://localhost:3000/license-filter (interactive license selection tool)
- Wiki pages: http://localhost:3000/wiki (policy documents from GitHub)
- Volunteer page: http://localhost:3000/volunteer (contributor showcase)
- Projects: http://localhost:3000/project (GitHub repository listings)
- Test API endpoints: Verify GitHub API integrations work
- Check responsive design: Test mobile/desktop layouts with React Bootstrap components
- Verify i18n functionality: Check Chinese/English language switching works
ALWAYS run before committing changes:
pnpm lint # Fix linting issues automatically
pnpm test # Runs linting + staged file checkspages/- Next.js pages and API routescomponents/- Reusable React components with Bootstrap stylingmodels/- MobX stores and data modelstranslation/- i18n language files (zh-CN, en-US, zh-TW)styles/- CSS and styling filespublic/- Static assets
package.json- Dependencies and scriptsnext.config.ts- Next.js configuration with MDX supporttsconfig.json- TypeScript configurationeslint.config.ts- ESLint configurationbabel.config.js- Babel configuration
- Next.js 15 - React framework
- React Bootstrap 2.10 - UI component library
- MobX 6.13 - State management
- mobx-github 0.4 - GitHub API integration
- mobx-i18n 0.7 - Internationalization
- license-filter 0.2 - License filtering functionality
- marked 16.2 - Markdown processing
Based on comprehensive PR review analysis, follow these critical development standards:
- ALWAYS use React Bootstrap components instead of custom HTML elements
- Use
<Button>,<Badge>,<Breadcrumb>,<Card>,<Container>from 'react-bootstrap' - Import from existing configured clients: use
githubClientfrommodels/Base.ts - Use utilities from established libraries:
treeFromfrom 'web-utility' - Import
'./Base'in model files for proper configuration
- Use GitHub API with ContentModel from mobx-github for content management
- Use configured
githubClientfrommodels/Base.tsfor authenticated API calls - Base64 decode content from GitHub API responses:
atob(item.content) - Replace filesystem reading with GitHub Contents API calls
- Use
ContentModel('owner', 'repo')pattern for repository content access
- Natural error throwing for static generation - let errors bubble up to catch build issues
- Don't catch errors in
getStaticPropsunless specifically handling them - Ensure build passes before pushing - resolve issues at compile time
// ✅ Correct - use React Bootstrap components
import { Button, Badge, Breadcrumb, Card, Container } from 'react-bootstrap';
<Button variant="outline-primary" size="sm" href={url} target="_blank">
{t('edit_on_github')}
</Button>
<Badge bg="secondary">{label}</Badge>
// ❌ Wrong - custom HTML elements
<a href={url} className="btn btn-outline-primary">Edit</a>
<span className="badge bg-secondary">{label}</span>- Use ordered lists (
<ol>) for countable items, unordered lists (<ul>) for navigation - Apply proper semantic structure:
<article>,<header>,<section> - Use
list-unstyledclass for first-level lists to remove default styling
// ✅ Correct - use optional chaining
node.parent_path?.split('/')
node.children?.length > 0
// ✅ Correct - let TypeScript infer types when possible
const renderTree = (nodes: WikiNode[], level = 0) => (
// No need for explicit return type annotation
)
// ❌ Wrong - verbose type annotations where inference works
const renderTree = (nodes: WikiNode[], level = 0): React.ReactElement => (// ✅ Correct - import from established sources
import { ContentModel } from 'mobx-github';
import { treeFrom } from 'web-utility';
import './Base'; // For configuration
// ✅ Correct - minimal exports
export const policyContentStore = new ContentModel('fpsig', 'open-source-policy');
// ❌ Wrong - unnecessary custom implementations
// Don't create new GitHub API clients when configured ones exist- ALL user-facing text MUST be translated using i18n system
- This includes button text, labels, error messages, placeholder text, and dynamic content
- Use the
t()function from I18nContext for all translations
// ✅ Correct - all text translated
const { t } = useContext(I18nContext);
<p>{t('no_docs_available')}</p>
<Button>{t('contribute_content')}</Button>
alert(t('operation_successful'));
// ❌ Wrong - hardcoded text
<p>暂无政策文档</p>
<Button>贡献内容</Button>
alert('操作成功');- Use generic terms unless specifically scoped:
t('knowledge_base')nott('policy_documents') - Add translation keys to ALL language files:
zh-CN.ts,en-US.ts,zh-TW.ts - Remove unused translation keys when replacing with generic ones
// ✅ Correct - use ContentModel with configured client
import { ContentModel } from 'mobx-github';
import './Base'; // Ensures githubClient configuration
export const policyContentStore = new ContentModel('fpsig', 'open-source-policy');
// Content processing with proper Base64 decoding
const content = item.content ? atob(item.content) : '';// ✅ Correct - use treeFrom utility for hierarchical data
import { treeFrom } from 'web-utility';
const tree = treeFrom(nodes, 'path', 'parent_path', 'children');- Use
ContentModelfor repository content access - Always decode Base64 content:
atob(item.content) - Import configured
githubClientfrommodels/Base.ts - Follow the pattern:
new ContentModel('owner', 'repository')
- GitHub API authentication is configured in
models/Base.ts - Use the configured client to avoid rate limiting and authentication issues
- Don't create separate GitHub API instances
- Run linting:
pnpm lintto auto-fix formatting - Check build: Ensure
pnpm buildpasses - Validate translations: Verify all text is properly translated
- Remove unused code: Clean up unused imports and translation keys
- Follow exact code suggestions from reviews when provided
- Use minimal approach - only include explicitly requested functionality
- Don't add extra features not specified in requirements
- Address reviewer feedback completely before requesting re-review
pnpm install # Install dependencies (1-3 minutes)
pnpm --version # Check pnpm versionpnpm dev # Start development server (5-15s)
pnpm build # Production build (30s-2min)
pnpm start # Start production serverpnpm lint # Run ESLint with auto-fix (15s)
pnpm test # Run tests (lint-staged + lint, 15s)- "Unsupported engine" warnings: Expected on Node.js <22, development still works
- Build hangs: Never cancel builds - they may take several minutes, set appropriate timeouts
- Missing dependencies: Always run
pnpm installfirst
- Custom HTML not working: Replace with React Bootstrap components
- Translation not showing: Ensure all text uses
t()function and keys exist in all language files - GitHub API errors: Verify you're using configured
githubClientfrommodels/Base.ts
- Base64 content errors: Use
atob(item.content)to decode GitHub API responses - Missing content: Check ContentModel configuration and repository access
- Tree structure problems: Use
treeFrom()utility from web-utility
- Clear browser cache if components don't render properly
- Restart development server after major configuration changes
- Verify all translation files are updated when adding new keys
- Uses GitHub ContentModel to access policy documents from
fpsig/open-source-policyrepository - Renders markdown content with front-matter metadata
- Supports hierarchical document structure with breadcrumb navigation
- Interactive multi-step license selection process
- Uses
license-filterpackage for license recommendation logic - Supports multiple languages with comprehensive i18n coverage
- Displays GitHub organization contributors
- Integrates with OSS Insight widgets for contributor analytics
- Uses GitHub API for real-time contributor data
Always prioritize these project-specific standards over generic Next.js or React guidance when working in this specific codebase.