把 markdown.processor 从 unified() 换成 Astro 7 的默认管线 satteri(),
并把原来 12 个 remark/rehype 插件逐一移植到 Sätteri 的 MDAST/HAST 插件模型。
内置能力直接替代(零代码)
- remark-math → features.math
- remark-directive → 未启用(见下)
- rehype-slug → satteriHeadingIdsPlugin()
新增 src/plugins/satteri/(6 个插件,约 200 行)
- reading-time.mjs after 钩子写 ctx.data.astro.frontmatter.minutes/words
- excerpt.mjs 取第一段写 frontmatter.excerpt
- shift-headings.mjs 工厂按 fileURL 判断,只对 posts 下的文章生效
- sectionize.mjs remark-sectionize 的等价实现(递归分组 + data.hName)
- autolink-headings.mjs 标题锚点,输出与 rehype-autolink-headings 逐字一致
- image-lightbox.mjs 上一版 rehype 图片灯箱的 HAST 版
删除(已迁移或本就无效)
- remark-reading-time / remark-excerpt / remark-shift-headings /
remark-directive-rehype / rehype-component-admonition /
rehype-image-lightbox —— 共 6 个旧插件文件
- 未启用 features.directive:内容里的 `::: tip`(冒号后有空格)和
`> [!tip] Tip` 在迁移前后都渲染成普通段落/引用,属于死语法;
保持现状以免升级顺手把它激活。
行为对齐
- smartPunctuation: { dashes: false } —— Astro 的 unified 管线会把直引号
排成弯引号但不转换 ---,Sätteri 默认会转,显式关掉 dashes 才能逐字一致。
验证(与 unified() 构建逐页对比,41 页)
- 正文 HTML 完全一致 35 页;把 HTML 实体和表格对齐写法归一化后,
只剩 3 页有差异:1 页是 KaTeX 尚未迁移(见下),2 页是中文/emoji 旁的
引号方向(Sätteri 的结果更正确)。
- meta description 仍由 excerpt 正确生成;阅读时长与基线一致。
- astro check:1 error / 0 warnings,与迁移前完全相同(原有 footer.astro 报错)。
- pnpm build 41 页通过;dev server 正常。
尚未迁移
- KaTeX:Sätteri 的 math 只负责解析,不渲染。数学公式目前落成
<code class="language-math">,是可见的回归,Phase 3 处理。
- package.json 里 remark-*/rehype-* 依赖暂未清理,等 Phase 3 确定后再收。
115 lines
3.7 KiB
JSON
115 lines
3.7 KiB
JSON
{
|
|
"name": "tianxuetao-blog",
|
|
"version": "0.1.0",
|
|
"private": true,
|
|
"type": "module",
|
|
"scripts": {
|
|
"dev": "astro dev",
|
|
"start": "astro dev",
|
|
"build": "node scripts/fetch-reading.mjs --soft && astro build && pagefind --site dist",
|
|
"preview": "astro preview",
|
|
"check": "astro check",
|
|
"new-post": "node scripts/new-post.mjs",
|
|
"new-thought": "node scripts/new-thought.mjs",
|
|
"reading": "node scripts/fetch-reading.mjs"
|
|
},
|
|
"dependencies": {
|
|
"@astrojs/markdown-remark": "^7.3.1",
|
|
"@astrojs/markdown-satteri": "^0.4.1",
|
|
"@astrojs/mdx": "^8.0.1",
|
|
"@astrojs/react": "^6.0.6",
|
|
"@astrojs/rss": "^4.0.19",
|
|
"@astrojs/sitemap": "^3.7.4",
|
|
"@aws-sdk/client-s3": "^3.1037.0",
|
|
"@expressive-code/core": "^0.44.2",
|
|
"@expressive-code/plugin-collapsible-sections": "^0.44.2",
|
|
"@expressive-code/plugin-line-numbers": "^0.44.2",
|
|
"@hookform/resolvers": "^3.10.0",
|
|
"@radix-ui/react-accordion": "1.2.2",
|
|
"@radix-ui/react-alert-dialog": "1.1.4",
|
|
"@radix-ui/react-aspect-ratio": "1.1.1",
|
|
"@radix-ui/react-avatar": "1.1.2",
|
|
"@radix-ui/react-checkbox": "1.1.3",
|
|
"@radix-ui/react-collapsible": "1.1.2",
|
|
"@radix-ui/react-context-menu": "2.2.4",
|
|
"@radix-ui/react-dialog": "1.1.4",
|
|
"@radix-ui/react-dropdown-menu": "2.1.4",
|
|
"@radix-ui/react-hover-card": "1.1.4",
|
|
"@radix-ui/react-label": "2.1.1",
|
|
"@radix-ui/react-menubar": "1.1.4",
|
|
"@radix-ui/react-navigation-menu": "1.2.3",
|
|
"@radix-ui/react-popover": "1.1.4",
|
|
"@radix-ui/react-progress": "1.1.1",
|
|
"@radix-ui/react-radio-group": "1.2.2",
|
|
"@radix-ui/react-scroll-area": "1.2.2",
|
|
"@radix-ui/react-select": "2.1.4",
|
|
"@radix-ui/react-separator": "1.1.1",
|
|
"@radix-ui/react-slider": "1.2.2",
|
|
"@radix-ui/react-slot": "1.1.1",
|
|
"@radix-ui/react-switch": "1.1.2",
|
|
"@radix-ui/react-tabs": "1.1.2",
|
|
"@radix-ui/react-toast": "1.2.4",
|
|
"@radix-ui/react-toggle": "1.1.1",
|
|
"@radix-ui/react-toggle-group": "1.1.1",
|
|
"@radix-ui/react-tooltip": "1.1.6",
|
|
"@swup/astro": "^1.8.0",
|
|
"@tabler/icons-react": "^3.40.0",
|
|
"astro-expressive-code": "^0.44.2",
|
|
"autoprefixer": "^10.4.20",
|
|
"bcryptjs": "^3.0.2",
|
|
"class-variance-authority": "^0.7.1",
|
|
"clsx": "^2.1.1",
|
|
"cmdk": "1.0.4",
|
|
"crypto-js": "^4.2.0",
|
|
"date-fns": "4.1.0",
|
|
"embla-carousel-react": "8.5.1",
|
|
"gray-matter": "^4.0.3",
|
|
"hastscript": "^9.0.1",
|
|
"input-otp": "1.4.1",
|
|
"katex": "^0.16.22",
|
|
"lucide-react": "^0.454.0",
|
|
"markdown-it": "^14.1.0",
|
|
"mdast-util-to-string": "^4.0.0",
|
|
"pagefind": "^1.4.0",
|
|
"react": "19.2.0",
|
|
"react-day-picker": "9.8.0",
|
|
"react-dom": "19.2.0",
|
|
"react-hook-form": "^7.60.0",
|
|
"react-resizable-panels": "^2.1.7",
|
|
"reading-time": "^1.5.0",
|
|
"recharts": "2.15.4",
|
|
"rehype-autolink-headings": "^7.1.0",
|
|
"rehype-components": "^0.3.0",
|
|
"rehype-katex": "^7.0.1",
|
|
"rehype-slug": "^6.0.0",
|
|
"remark-directive": "^3.0.1",
|
|
"remark-github-admonitions-to-directives": "^1.0.5",
|
|
"remark-math": "^6.0.0",
|
|
"remark-sectionize": "^2.1.0",
|
|
"sanitize-html": "^2.17.0",
|
|
"satteri": "^0.10.5",
|
|
"sonner": "^1.7.4",
|
|
"tailwind-merge": "^2.5.5",
|
|
"tailwindcss-animate": "^1.0.7",
|
|
"unist-util-visit": "^5.0.0",
|
|
"vaul": "^1.1.2",
|
|
"zod": "3.25.76"
|
|
},
|
|
"devDependencies": {
|
|
"@astrojs/check": "^0.9.6",
|
|
"@tailwindcss/postcss": "^4.1.9",
|
|
"@tailwindcss/typography": "^0.5.19",
|
|
"@types/crypto-js": "^4.2.2",
|
|
"@types/markdown-it": "^14.1.2",
|
|
"@types/node": "^22",
|
|
"@types/react": "^19",
|
|
"@types/react-dom": "^19",
|
|
"@types/sanitize-html": "^2.16.0",
|
|
"astro": "^7.3.3",
|
|
"postcss": "^8.5",
|
|
"tailwindcss": "^4.1.9",
|
|
"tw-animate-css": "1.3.3",
|
|
"typescript": "^5"
|
|
}
|
|
}
|