Skip to content

✨ refactor(wiki): migrate to content collection#35

Merged
nick-cjyx9 merged 4 commits intoopen-ani:mainfrom
mcontrib:refactor/wiki
Feb 9, 2026
Merged

✨ refactor(wiki): migrate to content collection#35
nick-cjyx9 merged 4 commits intoopen-ani:mainfrom
mcontrib:refactor/wiki

Conversation

@maxchang3
Copy link
Contributor

使用 Content Collection 重构了文档(wiki)页面。

  • remark-anchor-link 替换为 Astro 官方推荐的 rehype-autolink-headings。在 rehype 层处理锚点链接,避免影响 Astro 在 Markdown 相关的 API 中获取到的 heading.text 12。实际中,前者会在生成的 heading.text 的结果前添加一个 #
    • 需要使用 @astrojs/markdown-remark 中的 rehypeHeadingIds,确保标题 ID 可以被上述插件访问3
  • 定义 wiki 内容集合:
    • 使用动态路由生成 wiki 页面。
    • 优化部分文件中的排版,将文件重命名为英文 slug 以优化 SEO。
    • 添加 order 字段以支持自定义导航排序。
  • 优化 Doc.astro 界面,移除动态目录生成逻辑,使用生成的 headings,优化用户体验。

Footnotes

  1. https://docs.astro.build/en/guides/markdown-content/#importing-markdown

  2. https://docs.astro.build/en/reference/modules/astro-content/#render

  3. https://docs.astro.build/en/guides/markdown-content/#heading-ids-and-plugins

- Replace `remark-anchor-link` with `rehype-autolink-headings`. Handle anchor links at the rehype layer to avoid affecting Markdown headings in Astro
- Add `rehypeHeadingIds` from `@astrojs/markdown-remark` to ensure heading ids are available
- Define a `wiki` content collection and move wiki Markdown files to `src/content/wiki/`
  - Rename files to English slugs for improved SEO
  - Add an `order` field in frontmatter to support custom navigation sorting
- Refine `Doc.astro` UIs, and use generated headings
@WingChunWong
Copy link
Contributor

WingChunWong commented Feb 9, 2026

话说有没有什么方法可以让toc跳转不使用锚点(即#)进行页面内跳转,这样子浏览记录会爆炸的

Copy link
Member

@nick-cjyx9 nick-cjyx9 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@nick-cjyx9
Copy link
Member

话说有没有什么方法可以让toc跳转不使用锚点(即#)进行页面内跳转,这样子浏览记录会爆炸的

之前手动往 history push 了记录,删掉那行 history.pushState(null, "", href); 就行了

@maxchang3
Copy link
Contributor Author

Squash 成一个 commit 吧

@nick-cjyx9
Copy link
Member

ok

@nick-cjyx9 nick-cjyx9 merged commit 10ae615 into open-ani:main Feb 9, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants