Repository navigation
Conversation
- 新增 scripts/gen-announcements.mjs:从公告页 md 自动提取数据生成 JSON,predev/prebuild 钩子自动同步 - 新增 AnnouncementCards 组件:首页展示最新 6 条公告卡片,滚动交错浮入动画,点击跳转原文 - theme/index.tsx 覆写 HomeLayout,经 afterFeatures 插槽挂载(仅中文站) - 新增 /announcement/create 表单页:填写链接+标题实时预览卡片,生成 Markdown 片段,一键复制并跳转 GitHub 编辑页提交 PR - 首页公告区新增「创建公告」入口按钮 - 全部样式使用 Rspress 主题变量,深浅色自适应,prefers-reduced-motion 下关闭动画
- 公告数据独立为仓库根目录 announcements.md(从 docs/zh/announcement/index.md 迁出) - 公告页改为全量卡片墙:39 条全展示、按年份分组、blur-fade 滚动入场动画(纯 CSS,无新依赖) - 提取脚本支持无链接里程碑条目,渲染为不可点击的静态卡片 - 创建公告表单改走 Fork 流程:主按钮变为「Fork 仓库并编辑」,步骤说明更新;社团成员保留直链编辑入口 - GitHub 编辑链接指向新的 announcements.md
- 撤销「Fork 仓库并编辑」按钮:已 Fork 的提交者点 /fork 会碰壁 - 改为编辑直链:未 Fork 自动引导创建,已 Fork 自动在自己的 Fork 中编辑,仓库成员提示新建分支 - 步骤文案按三种身份说明,成员提示并入步骤
announcements.md 随本 PR 才合入 master,合并前本地预览点击 「去 GitHub 提交」会因 master 上无此文件而 404。 现检测 localhost 自动切换到 new_page 分支链接,并显示提示; 生产环境(非 localhost)仍指向 master,行为不变。
- 新增 GitHub 用户名字段与「检测我的 Fork」按钮:
调用免鉴权 API GET /repos/{user}/website 判断 Fork 是否存在
- 已 Fork(含仓库管理者)→ 提交按钮直达本人 Fork 编辑页;
未 Fork → 上游编辑链接,GitHub 自动引导创建
- 提示 Sync fork 同步要求;步骤与说明文案同步更新
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
动机
社团公告目前只能在公告页以纯链接列表展示,首页访客完全看不到社团动态;公告页本身也只是 Markdown 链接堆叠,缺少视觉层次;同时公告条目靠手写 Markdown,新成员容易写错格式。本 PR 一次性解决这三件事。
改动内容
1. 首页公告卡片区
theme/index.tsx的HomeLayout,通过官方afterFeatures插槽挂载,仅中文站启用prefers-reduced-motion下自动关闭--rp-c-*),浅色 / 深色主题自动适配2. 公告页全量卡片墙(
/announcement/)AnnouncementList组件:展示announcements.json的全部条目,按年份分组(新 → 旧),组头显示年份与条数.md升级为.mdx,直接挂载组件3. 「创建公告」表单页(
/announcement/create)localhost/127.0.0.1)时提交链接自动指向new_page分支,避免announcements.md尚未合入master导致的 404;正式上线后自动指回master4. 数据自动同步管线
docs/zh/announcement/index.md迁移到仓库根目录announcements.md:位置更醒目,编辑入口固定,贡献者一眼能找到scripts/gen-announcements.mjs:从announcements.md提取标题 / 日期 / 链接 / 来源,生成docs/components/announcements.json(自动倒序,最新在前)predev/prebuild钩子:维护者只维护公告一个文件,首页卡片与公告页自动同步,无需手工改两处支持的书写格式:
数据流
提交流程
/announcement/create填写原文链接与卡片标题,复制生成的 Markdown 片段announcements.md编辑页TSGU-OSC/website的master后提交本地验证
npm install npm run dev # predev 钩子会自动生成 docs/components/announcements.json/announcement/:确认年份分组与滚动入场动画/announcement/create:填写链接 / 标题,确认实时预览与片段生成说明与已知限制
docs/components/announcements.json:它由脚本生成,下次predev/prebuild会被覆盖,请改announcements.md变更规模
13 个文件,+1504 / -3,5 个 commit。