Repository navigation
S2-A:页面与组件(首页/列表/详情/分类/提交/关于 + 搜索筛选 + 主题三档) - #4
Merged
Merged
Conversation
mapxn
force-pushed
the
feat/s2-a-pages-components
branch
from
October 26, 2026 10:16
a740b50 to
a71a88b
Compare
- 页面:/ 首页、/projects/、/p/<slug>/、/categories/<slug>/、/submit/、/about/、404、sitemap.xml、robots.txt - 统一卡片组件 ProjectCard + 徽章体系(来源+等级金/绿/灰带文字、资源 >3 折叠 +n、难度、免费层、长期未更新/即将推出),首页/列表/分类页/详情页推荐共用同一实现 - 搜索 + 六维筛选 + 五种排序全部浏览器本地完成,状态写入 URL query(勾选/排序 pushState 可后退还原,搜索防抖 replaceState) - 主题三档(亮/暗/自动,默认自动,跟随系统实时切换,localStorage 持久化,head 内联脚本防闪烁) - 截图回退链:项目截图 → 构建期本地化的仓库 OG 图(public/og/github/)→ 分类着色首字图,禁止热链 GitHub - SEO:每页独立 title/description、详情页模板、canonical/OG/Twitter 恒写主域名、sitemap 含全部详情页与分类页 - 无障碍:axe-core 桌面/移动/暗色扫描 0 violations;页脚 git describe 版本 + 构建时间 + 第三方责任声明 - 依赖:@astrojs/react + React island、shadcn/ui 组件、Lucide、Radix;新增 scripts/fetch-og-images.ts;58 个测试(新增 16 条筛选/排序/入口规则用例)
mapxn
force-pushed
the
feat/s2-a-pages-components
branch
from
October 26, 2026 11:00
a71a88b to
bc1f0f4
Compare
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.
这是什么
S2-A(ONE-415):hub 的页面与组件。基于 S1-A 的 schema/管线与 S1-B 的 11 条数据,落地 SPEC v1.4 §2 / §4.3 / §8.2 / §8.3 / §10。
base 指向前置子单 PR #2 的 head 分支(
feat/s1-b-content-data);S1-A、S1-B 依次合入后会自动回落到main。页面(§2)
//projects//p/<slug>/listed未实测声明、coming-soon明示无部署入口/categories/<slug>//submit/CONTRIBUTING.md同源渲染(当前分支尚无该文件 → 显示占位说明,文件合入后自动接线,无需改代码)/about/404/sitemap.xml/robots.txthttps://hub.oneboy.app关键实现
src/components/project/project-card.tsx一个组件同时用于首页、列表(island 内)、分类页、详情页推荐。静态页里由 Astro 在构建期渲染成 HTML(不下发组件 JS),列表页 island 复用同一组件 → 三处徽章/入口不可能分叉。src/components/project/badges.tsx统一渲染来源+等级(金/绿/灰,全部带文字)、资源(>3 折叠+n)、难度、免费层、长期未更新/即将推出。src/lib/project-filter.ts,纯函数):搜索命中名称/tagline/长介绍/标签(中英);六维筛选;排序 = 默认(官方置顶 → 精选 → 收录日期倒序)/ star 降序 / 最近更新 / 名称 / 收录日期倒序;自动字段缺失时降级为收录日期。URL 状态:勾选与排序pushState(浏览器后退可还原上一步),搜索输入 300ms 防抖后replaceState(不刷历史);挂载后按window.location.search还原(静态托管同一份 HTML 服务所有 query,构建期拿不到访客 query)。URL 解析按 schema 枚举判合法:合法但当前 0 条结果的取值(如diff=1暂无项目)保留,脏值丢弃。localStorage持久化;<head>内联脚本在首屏绘制前应用darkclass(拦截全部 island JS 后仍正确 = 不依赖 React);自动档监听prefers-color-scheme实时跟随。scripts/fetch-og-images.ts,构建时抓取并本地化到public/og/github/,已随本 PR 提交 11 张缓存;页面只引用站内路径)→ 分类着色首字图。构建日志确认产物内没有任何opengraph.githubassets/githubusercontent外链。<项目名> — <一句话> | WorkerHub;canonical/og:url 由src/lib/site.ts常量拼绝对地址,从不读请求域名(镜像侧同样写主域名);OG/Twitter Card 齐备;sitemap 用手写 endpoint 而非官方集成(后者只产出sitemap-index.xml+ 分片,文件名与 §10 的sitemap.xml对不上)。@astrojs/react+ React island、shadcn/ui(Badge/Button/Input/Checkbox/Dialog/Dropdown/Separator)、Lucide、Radix、tw-animate-css;未自研等价组件。自测证据
pnpm build:24 页产出,全绿(fetch:meta11/11、OG 11/11)。pnpm lint:astro check0 errors / 0 warnings +prettier --check通过。pnpm test:58 个用例,57 pass / 1 skipped(需网络+token 的仓库 404 用例)/ 0 fail(新增 16 条筛选/排序/URL/入口规则用例)。GITHUB_API_BASE不可达 + 无缓存 +HUB_SKIP_OG=1→ 构建成功,11 条自动字段全部置空,页面正常渲染(卡片显示star —)。/p/not-a-real/返回 404、网络面板全站仅同源 GET、无登录入口。截图见 ONE-415 交付评论。与其他子单的对接
/submit/的同源坐标:仓库根CONTRIBUTING.md(S2-B / ONE-416 交付位置,契约不变)。文件合入后本页自动渲染正文。pnpm build增加一步tsx scripts/fetch-og-images.ts(失败不阻塞构建);CI 演练步骤加了HUB_SKIP_OG=1避免演练联网抓图。github-meta.json仅本地构建会滚动更新,已还原、不入本 PR)。待评审关注
public/og/github/11 张 OG 图作为本地化缓存入库(与 §9.2 缓存滚动更新的思路一致),避免每次构建都依赖 GitHub 的图片端点(本地实测该端点会 429);缺失时构建仍可跑,回退首字图。