feat: SEO 商用化 — robots/sitemap/OG/结构化数据 + 服务清单内置

- robots.txt:禁 /virtheart /api /unlock,含 sitemap 指向
- sitemap.xml:动态生成(首页 + 服务页 + 已发布作品详情)
- metadata:metadataBase/title template/keywords/canonical/OG/Twitter
  卡片/apple-icon,全部后台可改(site_title/description/keywords)
- search_verification 字段:百度站长验证 meta(后台填入即生效)
- JSON-LD:首页 Person 实体 + 服务页 ProfessionalService/ Offer
- og.png(1200×630)与 icon/apple-icon 品牌图(scripts/gen-brand-images.py)
- 页脚 ICP 备案号位(icp_beian,后台填入即显示,链工信部)
- 服务清单内置 7 项(Web/小程序、AI 应用、Flutter、Java/Go、
  产品设计、全栈交付、技术咨询),价格一律面议,DB 种子幂等

SEO 部署侧待办:百度/搜狗/360/Bing 站长平台提交与验证(填
search_verification 或放验证文件)、NEXT_PUBLIC_SITE_URL 指向正式域名。
This commit is contained in:
2026-09-02 18:48:44 +08:00
parent d666cedfc6
commit 7744a6b420
18 changed files with 419 additions and 19 deletions
+43 -5
View File
@@ -2,14 +2,17 @@ import type { Metadata } from "next";
import { WORK_ARTICLES } from "@/content/workArticles";
import { isPasscodeProtectedPath } from "@/lib/passcode";
import { getPasscodeAccessServer } from "@/lib/passcodeServer";
import { getSiteConfig, listWorks } from "@/lib/siteConfig";
import { absoluteUrl } from "@/lib/siteUrl";
/**
* Per-page <title>: the original detail route sets <title> to the work name
* (haoqi.design/reunimos → "Reunimos™"). The protected /2026 is gated on the
* server — without the access cookie its SSR title is "Protected"; once
* unlocked the server renders the article. We mirror both states. Lives in a
* segment layout so `params` contains the slug for both /work/[slug] and its
* root rewrite.
* unlocked the server renders the article. We mirror both states.
*
* SEO 增强:优先静态 WORK_ARTICLES,其次后台添加的作品(works 表),
* 生成 title / description / canonical / OG。
*/
export async function generateMetadata({
params,
@@ -20,10 +23,45 @@ export async function generateMetadata({
const path = `/${slug}`;
if (isPasscodeProtectedPath(path)) {
const access = await getPasscodeAccessServer();
if (!access[path]) return { title: "受保护内容" };
if (!access[path]) return { title: "受保护内容", robots: { index: false } };
}
const config = getSiteConfig();
const article = WORK_ARTICLES[path];
return { title: article ? article.title : "北极新一©2026" };
if (article) {
return {
title: article.title,
description: article.year || config.site_description,
alternates: { canonical: `/work/${slug}` },
openGraph: {
title: article.title,
type: "article",
url: absoluteUrl(`/work/${slug}`),
images: ["/og.png"],
},
};
}
// 后台添加的作品:works 表有文章字段则使用,否则只给基础元信息。
const row = listWorks(true).find((w) => w.slug === slug);
if (row) {
const desc =
row.article_markdown.trim().slice(0, 160) ||
`${row.name}${row.year ? `(${row.year})` : ""} — ${config.brand_name} 的作品。`;
return {
title: row.name,
description: desc,
alternates: { canonical: `/work/${slug}` },
openGraph: {
title: row.name,
description: desc,
type: "article",
url: absoluteUrl(`/work/${slug}`),
images: row.image_url ? [row.image_url] : ["/og.png"],
},
};
}
return { title: config.site_title, robots: { index: false } };
}
export default function WorkLayout({