Date: 2026-01-10 20:14 Summary: Componentized site layout (header/sidebar/footer/content) with i18n and tracking hooks for home and devlogs.
[question] 将网站分为header,sidebar,footer,content组件和部分,以便统一更新,例如多国语言,增加跟踪代码,同时需要很容易扩展语言支持。
[try to solve]
Implemented build-time component rendering under scripts/site/ (header/sidebar/footer/content), with i18n (t(lang,key) dictionary + configurable language list) and tracking injection hooks (env-driven <head> / <body> snippets). Unified entry scripts/build-site.mjs generates the home page and devlogs (index + per-log pages). scripts/build-logs.mjs became a thin wrapper for command compatibility.
Multilingual: SITE_LANGS=zh,en enables multi-language output (default was zh-only), with hreflang alternates and a header language switcher.
Tracking: set SITE_TRACKING_HEAD_HTML / SITE_TRACKING_BODY_HTML and rebuild to apply site-wide.
Fix: keep scripts/build-site.mjs from running main on import so npm run build:logs only builds devlogs.
[actions]
- Added
scripts/site/config.mjs,i18n.mjs,tracking.mjs,components.mjs,layout.mjs,pages/home.mjs - Added
scripts/build-site.mjs - Refactored
scripts/build-logs.mjs - Updated
package.json(build:site),README.md - Generated
public/index.html,public/devlogs/index.html,public/devlogs/*.html