import { useEffect, useRef } from 'react' import { t, type Language } from '../../i18n/translations' import type { FAQCategory } from '../../data/faqData' // RoadmapWidget 移除动态嵌入,按需仅展示外部链接 interface FAQContentProps { categories: FAQCategory[] language: Language onActiveItemChange: (itemId: string) => void } export function FAQContent({ categories, language, onActiveItemChange, }: FAQContentProps) { const sectionRefs = useRef>(new Map()) useEffect(() => { const observer = new IntersectionObserver( (entries) => { entries.forEach((entry) => { if (entry.isIntersecting) { const itemId = entry.target.getAttribute('data-item-id') if (itemId) { onActiveItemChange(itemId) } } }) }, { rootMargin: '-100px 0px -80% 0px', threshold: 0, } ) sectionRefs.current.forEach((ref) => { if (ref) observer.observe(ref) }) return () => { sectionRefs.current.forEach((ref) => { if (ref) observer.unobserve(ref) }) } }, [onActiveItemChange]) const setRef = (itemId: string, element: HTMLElement | null) => { if (element) { sectionRefs.current.set(itemId, element) } else { sectionRefs.current.delete(itemId) } } return (
{categories.map((category) => (
{/* Category Header */}

{t(category.titleKey, language)}

{/* FAQ Items */}
{category.items.map((item) => (
setRef(item.id, el)} className="scroll-mt-24" > {/* Question */}

{t(item.questionKey, language)}

{/* Answer */}
{item.id === 'github-projects-tasks' ? (
    {language === 'zh' ? ( <>
  1. 打开以上链接,按标签筛选(good first issue / help wanted / frontend / backend)。
  2. 打开任务,阅读描述与验收标准(Acceptance Criteria)。
  3. 评论“assign me”或自助分配(若权限允许)。
  4. Fork 仓库到你的 GitHub 账户。
  5. 同步你的 fork 的 dev{' '} 分支与上游保持一致: git remote add upstream https://github.com/NoFxAiOS/nofx.git
    git fetch upstream
    git checkout dev
    git rebase upstream/dev
    git push origin dev
  6. 从你的 fork 的 dev 建立特性分支: git checkout -b feat/your-topic
  7. 推送到你的 fork: git push origin feat/your-topic
  8. 打开 PR:base 选择 NoFxAiOS/nofx:dev{' '} ← compare 选择{' '} 你的用户名/nofx:feat/your-topic
  9. 在 PR 中关联 Issue(示例: Closes #123 ),选择正确 PR 模板;必要时与{' '} upstream/dev{' '} 同步(rebase)后继续推送。
  10. ) : ( <>
  11. Open the links above and filter by labels (good first issue / help wanted / frontend / backend).
  12. Open the task and read the Description & Acceptance Criteria.
  13. Comment "assign me" or self-assign (if permitted).
  14. Fork the repository to your GitHub account.
  15. Sync your fork's dev with upstream: git remote add upstream https://github.com/NoFxAiOS/nofx.git
    git fetch upstream
    git checkout dev
    git rebase upstream/dev
    git push origin dev
  16. Create a feature branch from your fork's{' '} dev: git checkout -b feat/your-topic
  17. Push to your fork: git push origin feat/your-topic
  18. Open a PR: base NoFxAiOS/nofx:dev ← compare{' '} your-username/nofx:feat/your-topic.
  19. In PR, reference the Issue (e.g.,{' '} Closes #123) and choose the proper PR template; rebase onto{' '} upstream/dev as needed.
  20. )}
{language === 'zh' ? (
提示:{' '} 参与贡献将享有激励制度(如 Bounty/奖金、荣誉徽章与鸣谢、优先 Review/合并与内测资格 等)。 可在任务中优先选择带 bounty 标签 的事项,或完成后提交 Bounty Claim 申请。
) : (
Note:{' '} Contribution incentives are available (e.g., cash bounties, badges & shout-outs, priority review/merge, beta access). Prefer tasks with bounty label , or file a Bounty Claim after completion.
)}
) : item.id === 'contribute-pr-guidelines' ? (
{language === 'zh' ? '参考文档:' : 'References:'}{' '} CONTRIBUTING.md {' | '} PR_TITLE_GUIDE.md
    {language === 'zh' ? ( <>
  1. Fork 仓库后,从你的 fork 的 dev{' '} 分支创建特性分支;避免直接向上游 main{' '} 提交。
  2. 分支命名:feat/…、fix/…、docs/…;提交信息遵循 Conventional Commits。
  3. 提交前运行检查: npm --prefix web run lint && npm --prefix web run build
  4. 涉及 UI 变更请附截图或短视频。
  5. 选择正确的 PR 模板(frontend/backend/docs/general)。
  6. 在 PR 中关联 Issue(示例: Closes #123),PR 目标选择 NoFxAiOS/nofx:dev
  7. 保持与 upstream/dev{' '} 同步(rebase),确保 CI 通过;尽量保持 PR 小而聚焦。
  8. ) : ( <>
  9. After forking, branch from your fork's{' '} dev; avoid direct commits to upstream{' '} main.
  10. Branch naming: feat/…, fix/…, docs/…; commit messages follow Conventional Commits.
  11. Run checks before PR: npm --prefix web run lint && npm --prefix web run build
  12. For UI changes, attach screenshots or a short video.
  13. Choose the proper PR template (frontend/backend/docs/general).
  14. Link the Issue in PR (e.g.,{' '} Closes #123) and target NoFxAiOS/nofx:dev.
  15. Keep rebasing onto upstream/dev, ensure CI passes; prefer small and focused PRs.
  16. )}
{language === 'zh' ? (
Note:{' '} 我们为高质量贡献提供激励(Bounty/奖金、荣誉徽章与鸣谢、优先 Review/合并与内测资格 等)。 详情可关注带 bounty 标签 的任务,或使用 Bounty Claim 模板 提交申请。
) : (
Note:{' '} We offer contribution incentives (bounties, badges, shout-outs, priority review/merge, beta access). Look for tasks with bounty label , or submit a Bounty Claim when ready.
)}
) : (

{t(item.answerKey, language)}

)}
{/* Divider */}
))}
))}
) }