CLAUDE.md — liweinan.github.io 技术博客项目规则
CLAUDE.md — liweinan.github.io 技术博客项目规则
博客文章写作规则
文件命名
- 格式:
_posts/YYYY-MM-DD-主题关键词.md - 文件名日期固定使用”当前日期减一天”(避免时区导致当天文章不渲染)
Front Matter
- 只包含
title: "标题"字段,除非确需额外字段 - 标题中避免嵌套引号,使用书名号「」代替
- 文章包含 Mermaid 图表时必须添加 `
.mermaid-container:hover { opacity: 0.8; }
.mermaid-container svg { max-width: 100%; height: auto; display: block; }
/* Modal overlay */ .mermaid-modal { display: none; position: fixed; z-index: 9999; left: 0; top: 0; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.9); animation: fadeIn 0.3s; }
.mermaid-modal.active { display: flex; align-items: center; justify-content: center; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
/* Modal content */ .mermaid-modal-content { position: relative; width: 90vw; height: 90vh; overflow: hidden; background: white; padding: 20px; border-radius: 8px; box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); display: flex; align-items: center; justify-content: center; }
.mermaid-modal-diagram { transform-origin: center center; transition: transform 0.2s ease; display: inline-block; min-width: 100%; cursor: grab; user-select: none; }
.mermaid-modal-diagram.dragging { cursor: grabbing; transition: none; }
.mermaid-modal-diagram svg { width: 100%; height: auto; display: block; pointer-events: none; }
/* Control buttons */ .mermaid-controls { position: absolute; top: 10px; right: 10px; display: flex; gap: 8px; z-index: 10000; }
.mermaid-btn { background: rgba(255, 255, 255, 0.9); border: 1px solid #ddd; border-radius: 4px; padding: 8px 12px; cursor: pointer; font-size: 14px; transition: background 0.2s; color: #333; font-weight: 500; }
.mermaid-btn:hover { background: white; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); }
/* Close button */ .mermaid-close { background: #f44336; color: white; border: none; }
.mermaid-close:hover { background: #d32f2f; }
/* Zoom indicator */ .mermaid-zoom-level { position: absolute; bottom: 20px; left: 20px; background: rgba(0, 0, 0, 0.7); color: white; padding: 6px 12px; border-radius: 4px; font-size: 14px; z-index: 10000; } </style>
`
写作风格
- 概念先行,细节在后:先以一句话或简短段落提纲挈领地概括核心思想,再展开具体细节和源码分析。让读者先建立直觉,再深入求证
- 关键概念段落中,用一个具体的对比(如 O(1) vs O(n))锚定抽象概念,使读者立即理解”为什么这个设计是必要的”
代码块规范
- 从实际源码文件引用代码时,必须在代码块首行以注释标注相对仓库根的文件名和行号:
// tokio/src/time/sleep.rs: 220-232Rust/C/C++ 使用
//,Python 使用#,等 - 代码块语言标识符使用 Rouge 支持的类型:
rust,c,python,bash,yaml,json,text等 - 所有源码引用必须使用 GitHub 链接(
https://github.com/owner/repo/blob/...),不使用本地绝对路径
引用规范
- 每个技术引用包含: 作者名、仓库名、commit hash(带 GitHub 链接)、commit 标题(斜体)、简短说明
- 所有陈述和转述都必须有具体来源链接,避免”有人提出”、”据报道”等无明确出处的说法
- References 使用脚注格式
[^1]:放在文末
Mermaid 图表
sequenceDiagram的participant中不使用<br/>,用括号代替- 箭头不留空格:
->>而非- >> - 每篇文章建议 3-5 个图表
- 发布前用
npx @mermaid-js/mermaid-cli验证所有图表
Git 提交
- 格式:
docs(post): <简短描述> - 末尾添加
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>