{title}
+ {description &&{description}
} +diff --git a/.gitignore b/.gitignore index cec5060..ea870f8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,7 @@ # Dependencies node_modules/ +.astro/ +dist/ # macOS-specific files. .DS_Store diff --git a/PR_DESCRIPTION.md b/PR_DESCRIPTION.md new file mode 100644 index 0000000..0364bcd --- /dev/null +++ b/PR_DESCRIPTION.md @@ -0,0 +1,158 @@ +# PR: Blog SEO Quality Checker — 博客 SEO 质量检查器 + +## Summary + +为 [floatboatai/open-saas-interview](https://github.com/floatboatai/open-saas-interview) 实现 **Blog SEO Quality Checker**:自动检测博客文章常见 SEO 问题,输出 0–100 评分与优先级排序的修复建议。 + +- **选题**:Blog SEO 质量检查器(中级) +- **岗位匹配**:SEO 工程化 / 全栈(TypeScript + Astro + API) +- **Fork 提交**:`klj121616/open-saas-interview` → PR 至 `floatboatai/open-saas-interview` + +--- + +## 做了什么 + +### 功能模块 + +| 模块 | 文件 | 职责 | +|------|------|------| +| SEO 分析引擎 | `src/lib/seo-checker.ts` | 7 类检查、加权评分、修复建议 | +| 内容解析层 | `src/lib/blog-content.ts` | Markdown → 结构化输入,API/页面共用 | +| HTTP API | `src/pages/api/seo-check.ts` | `GET ?slug=` 返回 JSON 审计报告 | +| 可视化组件 | `src/components/SeoScore.tsx` | 分数徽章 + findings 详情 | +| 博客页面 | `src/pages/blog/[slug].astro` | 文章 + 侧边 SEO 面板 | +| Demo 导航 | `src/pages/index.astro` | 入口页,链接到博客与 API | +| 内容集合 | `src/content/` | Zod Schema + 示例文章 | + +### 7 类 SEO 检查 + +| 检查项 | 严重级别 | 典型扣分 | +|--------|---------|---------| +| 标题长度 | critical / warning / info | 最高 -25 | +| Meta 描述 | critical / warning | 最高 -20 | +| Canonical URL | critical / warning | 最高 -15 | +| H1/H2 结构 | critical / warning | 最高 -25 | +| 图片 Alt | warning / info | -3/张 | +| 内链数量 | warning / info | -8 | +| 正文字数 | critical / info | 最高 -30 | + +--- + +## 设计决策 + +### 1. 三层架构(引擎 / 解析 / 集成) + +``` +Markdown + Frontmatter + ↓ +blog-content.ts → BlogPostContent + ↓ +seo-checker.ts → SeoAuditReport + ↓ +API / 博客页 / SeoScore +``` + +**取舍**:引擎零框架依赖,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 无 `#` 时,用 frontmatter `title` 作为 H1(与页面模板 `
{f.issue}
+ -{f.penalty} pts +💡 {f.suggestion}
+{description}
} +Open SaaS interview demo. Root / has no landing page by design — use the routes below.