feat: add Blog SEO Quality Checker#2
Open
leshihu wants to merge 4 commits into
Open
Conversation
- Core SEO analysis engine with 7 independent check functions - Weighted scoring system (100 = perfect, deduct per issue) - 27 unit tests covering structure, quality, and edge cases - GET /api/seo-check?slug=xxx API endpoint - SeoScore React component for visual scoring
- Fix ESLint errors in API endpoint and test files - Add vitest to devDependencies for unit test support - Add src/content/config.ts with blog collection schema - Add sample blog post for demonstration - Add blog post page ([slug].astro) with integrated SEO score display - Add astro.config.mjs for project configuration
Add blog-content parser, demo index page, vitest config, and Astro 5 stability fixes. All 73 automated tests pass; dev routes verified. Co-authored-by: Cursor <cursoragent@cursor.com>
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.
PR: Blog SEO Quality Checker — 博客 SEO 质量检查器
Summary
为 floatboatai/open-saas-interview 实现 Blog SEO Quality Checker:自动检测博客文章常见 SEO 问题,输出 0–100 评分与优先级排序的修复建议。
klj121616/open-saas-interview→ PR 至floatboatai/open-saas-interview做了什么
功能模块
src/lib/seo-checker.tssrc/lib/blog-content.tssrc/pages/api/seo-check.tsGET ?slug=返回 JSON 审计报告src/components/SeoScore.tsxsrc/pages/blog/[slug].astrosrc/pages/index.astrosrc/content/7 类 SEO 检查
设计决策
1. 三层架构(引擎 / 解析 / 集成)
取舍:引擎零框架依赖,Vitest 可直接单测;换框架只改解析层。
2. 扣分制评分(非 pass/fail)
SEO 优化是渐进的。100 分起扣,权重按 Google SERP 指南设定(标题 50–60 字、描述 120–155 字等)。
3. 检查函数返回
SeoFinding[]同一维度可有多问题(如缺 H1 + H2 不足),数组模型更自然,引擎统一按 severity → penalty 排序。
4. 博客页 build-time 审计 + API 供外部调用
页面 SSG 时直接
auditSeo(),无网络往返;API 供 CI、批量工具使用。两者共用buildBlogPostContent(),分数一致。5. H1 回退策略
Markdown 无
#时,用 frontmattertitle作为 H1(与页面模板<h1>一致)。6. 双测试策略
npm test边界处理
如何验证(Reviewer)
环境要求
npm install后 vitest 报模块缺失,删除node_modules+package-lock.json重装自动化测试
手动验证(开发服务器)
预期:博客页显示约 87 分,有「内链不足」「字数偏短」等 findings;API 返回同结构 JSON。
已知局限
npm run build需 SSR adapter(API 为动态路由prerender = false);开发演示以npm run dev为准SeoScore使用 Tailwind class,未接入 Tailwind 时配色可能不完整(分数与文案正常)Test Plan
npm test全部通过npm run test:vitest全部通过npm run lint无 errornpm run dev首页、博客页、API 均可访问description为空后,分数下降且出现 critical finding后续规划
criticalOnly()阻断发布;API 改为[slug]静态 JSON 以支持npm run build自我评估