Commit 03495e5
committed
post(gin): 归档 Gin 框架原稿 + 纯 markdown 渲染分支
新文章 content/posts/gin-framework-notes.md 是原稿存档,正文一字未动。
原文中混有大量裸 C++/PCL 代码片段(<iostream>、pcl::PointCloud<pcl::PointXYZ>、
裸 { } 等),MDX 会把它们当 JSX/JS 表达式解析并报错,导致 build 失败。
为此在 src/lib/markdown.ts 增加 renderPlainMarkdown:基于
unified + remark-parse + remark-gfm + remark-rehype + rehype-stringify
的纯 markdown 管道,跳过 MDX 表达式解析。复用同一组 rehype 插件
(rehypeShiki / rehypeHeadings / rehypeImgAttrs / rehypeExternalLinks),
确保 TOC 锚点、代码高亮、图片懒加载、外链 rel 与 MDX 路径完全一致。
PLAIN_MARKDOWN_SLUGS 是显式白名单,目前只含 gin-framework-notes,
src/app/blog/[slug]/page.tsx 据此分支:白名单走 dangerouslySetInnerHTML,
其余仍走 next-mdx-remote。
依赖:unified / remark-parse / remark-rehype 提升为直接依赖
(之前是 next-mdx-remote 的间接依赖)。
build 验证:42/42 静态页生成成功,含 /blog/gin-framework-notes、
/tags/gin、/tags/编程 等页面。1 parent cef51a5 commit 03495e5
6 files changed
Lines changed: 1196 additions & 7 deletions
File tree
- content/posts
- public
- src
- app/blog/[slug]
- lib
Large diffs are not rendered by default.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
| 28 | + | |
27 | 29 | | |
28 | | - | |
| 30 | + | |
| 31 | + | |
29 | 32 | | |
30 | 33 | | |
31 | 34 | | |
| |||
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| |||
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
78 | | - | |
79 | | - | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
80 | 82 | | |
81 | 83 | | |
82 | 84 | | |
| |||
179 | 181 | | |
180 | 182 | | |
181 | 183 | | |
182 | | - | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
183 | 189 | | |
184 | 190 | | |
185 | 191 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
6 | 10 | | |
7 | 11 | | |
8 | 12 | | |
| |||
12 | 16 | | |
13 | 17 | | |
14 | 18 | | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
15 | 30 | | |
16 | 31 | | |
17 | 32 | | |
| |||
194 | 209 | | |
195 | 210 | | |
196 | 211 | | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
197 | 245 | | |
198 | 246 | | |
199 | 247 | | |
| |||
0 commit comments