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:
+38
-2
@@ -9,6 +9,7 @@ import { FullscreenTransitionProvider } from "@/lib/routeTransition";
|
||||
import RouteTransitionOverlay from "@/components/dom/RouteTransitionOverlay";
|
||||
import { getPasscodeAccessServer } from "@/lib/passcodeServer";
|
||||
import { getSiteConfig } from "@/lib/siteConfig";
|
||||
import { SITE_URL } from "@/lib/siteUrl";
|
||||
import type { Metadata } from "next";
|
||||
|
||||
/**
|
||||
@@ -19,9 +20,44 @@ import type { Metadata } from "next";
|
||||
*/
|
||||
export async function generateMetadata(): Promise<Metadata> {
|
||||
const config = getSiteConfig();
|
||||
const title = config.site_title;
|
||||
const description = config.site_description;
|
||||
return {
|
||||
title: config.site_title,
|
||||
description: config.site_description,
|
||||
metadataBase: new URL(SITE_URL),
|
||||
title: {
|
||||
default: title,
|
||||
template: `%s · ${config.brand_name || "北极新一"}`,
|
||||
},
|
||||
description,
|
||||
keywords: config.seo_keywords
|
||||
? config.seo_keywords.split(/[,,]/).map((k) => k.trim()).filter(Boolean)
|
||||
: undefined,
|
||||
verification: config.search_verification
|
||||
? { other: { "baidu-site-verification": config.search_verification } }
|
||||
: undefined,
|
||||
alternates: { canonical: "/" },
|
||||
icons: {
|
||||
icon: [
|
||||
{ url: "/icon.png", sizes: "192x192", type: "image/png" },
|
||||
{ url: "/favicon.ico", sizes: "any" },
|
||||
],
|
||||
apple: "/apple-icon.png",
|
||||
},
|
||||
openGraph: {
|
||||
type: "website",
|
||||
siteName: config.brand_name || "北极新一",
|
||||
title,
|
||||
description,
|
||||
url: SITE_URL,
|
||||
locale: "zh_CN",
|
||||
images: [{ url: "/og.png", width: 1200, height: 630, alt: title }],
|
||||
},
|
||||
twitter: {
|
||||
card: "summary_large_image",
|
||||
title,
|
||||
description,
|
||||
images: ["/og.png"],
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
+4
-1
@@ -4,6 +4,7 @@ import FooterSection from "@/components/dom/FooterSection";
|
||||
import WorkSection from "@/components/dom/WorkSection";
|
||||
import HyperSpaceSection from "@/components/dom/HyperSpaceSection";
|
||||
import PasscodeRevealText from "@/components/dom/PasscodeRevealText";
|
||||
import { PersonJsonLd } from "@/components/dom/PersonJsonLd";
|
||||
import { getSiteConfig, listWorks } from "@/lib/siteConfig";
|
||||
import type { WorkItem } from "@/lib/workItems";
|
||||
|
||||
@@ -32,6 +33,8 @@ export default async function Home() {
|
||||
// Lenis is window-level, so main must NOT be a scroll container —
|
||||
// otherwise sticky (hyper-space section) never pins.
|
||||
<main className="w-full">
|
||||
{/* 结构化数据:个人实体(SEO 富结果) */}
|
||||
<PersonJsonLd />
|
||||
<div>
|
||||
{/* Banner Section */}
|
||||
<div
|
||||
@@ -122,7 +125,7 @@ export default async function Home() {
|
||||
<HyperSpaceSection />
|
||||
|
||||
{/* Contact / Footer Section (#contact, data-section="footer") */}
|
||||
<FooterSection contactEmail={config.contact_email} />
|
||||
<FooterSection contactEmail={config.contact_email} icpBeian={config.icp_beian} />
|
||||
</div>
|
||||
</main>
|
||||
);
|
||||
|
||||
@@ -1,10 +1,19 @@
|
||||
import type { Metadata } from "next";
|
||||
import ServicesClient from "./ServicesClient";
|
||||
import { getSiteConfig, listServices } from "@/lib/siteConfig";
|
||||
import { absoluteUrl } from "@/lib/siteUrl";
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "服务 · 北极新一",
|
||||
description: "可提供的服务 — 选择你需要的服务,留言告诉我",
|
||||
title: "服务",
|
||||
description:
|
||||
"Web / 小程序开发、AI 应用与 Agent 原型、Flutter 跨端客户端、Java/Go 后端、产品设计与全栈交付 — 选择你需要的服务,留言告诉我。",
|
||||
alternates: { canonical: "/services" },
|
||||
openGraph: {
|
||||
title: "服务 · 北极新一",
|
||||
type: "website",
|
||||
url: absoluteUrl("/services"),
|
||||
images: ["/og.png"],
|
||||
},
|
||||
};
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
@@ -18,11 +27,39 @@ export default function ServicesPage() {
|
||||
description: s.description,
|
||||
priceNote: s.price_note,
|
||||
}));
|
||||
|
||||
// 结构化数据:ProfessionalService(Google/Bing 富结果用)
|
||||
const jsonLd = {
|
||||
"@context": "https://schema.org",
|
||||
"@type": "ProfessionalService",
|
||||
name: `${config.brand_name} — 数字产品设计与开发`,
|
||||
url: absoluteUrl("/services"),
|
||||
email: config.contact_email,
|
||||
areaServed: "CN",
|
||||
availableLanguage: ["zh-CN"],
|
||||
makesOffer: services.map((s) => ({
|
||||
"@type": "Offer",
|
||||
name: s.title,
|
||||
itemOffered: {
|
||||
"@type": "Service",
|
||||
name: s.title,
|
||||
description: s.description,
|
||||
},
|
||||
})),
|
||||
};
|
||||
|
||||
return (
|
||||
<ServicesClient
|
||||
headline={config.services_hero}
|
||||
submitNote={config.services_submit_note}
|
||||
services={services}
|
||||
/>
|
||||
<>
|
||||
<script
|
||||
type="application/ld+json"
|
||||
// 结构化数据为服务端生成的静态 JSON,无用户输入。
|
||||
dangerouslySetInnerHTML={{ __html: JSON.stringify(jsonLd) }}
|
||||
/>
|
||||
<ServicesClient
|
||||
headline={config.services_hero}
|
||||
submitNote={config.services_submit_note}
|
||||
services={services}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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({
|
||||
|
||||
Reference in New Issue
Block a user