Skip to content

feat(docs): 新增脚本以自动生成 CommunityShare 索引页#110

Open
LynPtl wants to merge 1 commit intoInvolutionHell:mainfrom
LynPtl:feat/generate-index-script
Open

feat(docs): 新增脚本以自动生成 CommunityShare 索引页#110
LynPtl wants to merge 1 commit intoInvolutionHell:mainfrom
LynPtl:feat/generate-index-script

Conversation

@LynPtl
Copy link
Copy Markdown
Contributor

@LynPtl LynPtl commented Sep 21, 2025

Purpose:
为了解决 CommunityShare 索引页 (index.mdx) 需要手动维护的问题,本次提交引入了一个自动化的 Node.js 脚本。该脚本能够根据实际文件目录结构,动态生成一个结构清晰、链接准确、始终保持最新的索引页。

Key Changes:
新增索引生成脚本:
在 scripts/ 目录下添加了 generate-community-index.js 文件。
更新索引页:
使用新脚本生成了最新的 app/docs/CommunityShare/index.mdx 文件,以展示脚本的运行效果。
脚本核心功能 (Script Features)
自动扫描: 脚本会自动扫描 CommunityShare 下的所有分类目录(如 Geek, computer-science 等)。
支持多级嵌套: 能够正确处理任意深度的目录结构(例如 .../data-structures/array/),并生成对应的层级缩进。
智能排序: 在每个目录层级中,index.mdx (作为该层级的概述页) 会被优先排列,其余文件则按字母顺序排序。
读取元数据: 脚本会自动读取每个 .mdx 文件头部的 Frontmatter,使用其中定义的 title作为链接的显示文本。

How to Use:
在项目根目录下运行以下命令即可更新索引:
node scripts/generate-community-index.js

Next Steps:
依赖库glob和gray-matter由于我配置原因未写入package.json,在此之后才能做GitHub Actions。
没玩明白GitHub Actions workflows工作流,需要集成才能实现自动化。

@vercel
Copy link
Copy Markdown

vercel bot commented Sep 21, 2025

@LynPtl is attempting to deploy a commit to the Yoyo's projects Team on Vercel.

A member of the Team first needs to authorize it.

@longsizhuo
Copy link
Copy Markdown
Member

@TSK-Glofy TSK看看

Copy link
Copy Markdown
Contributor

@TSK-Glofy TSK-Glofy left a comment

Choose a reason for hiding this comment

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

本地测试无误,但需要添加globgray-matter依赖
同时workflow需要在.github/workflows/deploy.yml中添加run: node scripts/generate-community-index.js

@longsizhuo
Copy link
Copy Markdown
Member

fumadocs自带的api, source.getPage是不是就可以满足需求

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants