mirror of
https://github.com/NanmiCoder/cc-haha
synced 2026-07-30 16:23:35 +08:00
The site already ships both languages, but / always served Chinese, so English readers had to find the switcher themselves. A Chinese browser now stays on /, everything else lands on /en. The decision runs as an inline script in index.html, next to the existing theme anti-flash block: deferring it to React would show English readers a full screen of Chinese first. It only fires on the root path — /en, /start and /en/start are deliberate destinations, and redirecting those would kick readers off any cross-language link they follow. A manual switch is stored in localStorage and wins over the browser language, otherwise switching would be undone on the next visit to the home page. resolveRootRedirect carries the same rules as a testable pure function. check-docs asserts the inline copy and the module agree on the storage key, the Chinese tag pattern and the root-only guard, so the two cannot drift.
29 lines
781 B
JSON
29 lines
781 B
JSON
{
|
|
"name": "claude-code-haha-site",
|
|
"version": "0.1.0",
|
|
"private": true,
|
|
"type": "module",
|
|
"scripts": {
|
|
"predev": "node scripts/generate-docs-manifest.mjs",
|
|
"dev": "vite --host 0.0.0.0",
|
|
"prebuild": "node scripts/generate-docs-manifest.mjs",
|
|
"build": "vite build",
|
|
"postbuild": "node scripts/prepare-static-output.mjs",
|
|
"preview": "vite preview --host 0.0.0.0",
|
|
"check:docs": "node scripts/check-docs.mjs",
|
|
"test": "node --test \"src/**/*.test.js\"",
|
|
"check": "npm run check:docs && npm test"
|
|
},
|
|
"dependencies": {
|
|
"dompurify": "^3.3.0",
|
|
"highlight.js": "^11.11.1",
|
|
"marked": "^17.0.5",
|
|
"mermaid": "^11.14.0",
|
|
"react": "^19.2.4",
|
|
"react-dom": "^19.2.4"
|
|
},
|
|
"devDependencies": {
|
|
"vite": "^8.0.10"
|
|
}
|
|
}
|