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 RouteTransitionOverlay from "@/components/dom/RouteTransitionOverlay";
|
||||||
import { getPasscodeAccessServer } from "@/lib/passcodeServer";
|
import { getPasscodeAccessServer } from "@/lib/passcodeServer";
|
||||||
import { getSiteConfig } from "@/lib/siteConfig";
|
import { getSiteConfig } from "@/lib/siteConfig";
|
||||||
|
import { SITE_URL } from "@/lib/siteUrl";
|
||||||
import type { Metadata } from "next";
|
import type { Metadata } from "next";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -19,9 +20,44 @@ import type { Metadata } from "next";
|
|||||||
*/
|
*/
|
||||||
export async function generateMetadata(): Promise<Metadata> {
|
export async function generateMetadata(): Promise<Metadata> {
|
||||||
const config = getSiteConfig();
|
const config = getSiteConfig();
|
||||||
|
const title = config.site_title;
|
||||||
|
const description = config.site_description;
|
||||||
return {
|
return {
|
||||||
title: config.site_title,
|
metadataBase: new URL(SITE_URL),
|
||||||
description: config.site_description,
|
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 WorkSection from "@/components/dom/WorkSection";
|
||||||
import HyperSpaceSection from "@/components/dom/HyperSpaceSection";
|
import HyperSpaceSection from "@/components/dom/HyperSpaceSection";
|
||||||
import PasscodeRevealText from "@/components/dom/PasscodeRevealText";
|
import PasscodeRevealText from "@/components/dom/PasscodeRevealText";
|
||||||
|
import { PersonJsonLd } from "@/components/dom/PersonJsonLd";
|
||||||
import { getSiteConfig, listWorks } from "@/lib/siteConfig";
|
import { getSiteConfig, listWorks } from "@/lib/siteConfig";
|
||||||
import type { WorkItem } from "@/lib/workItems";
|
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 —
|
// Lenis is window-level, so main must NOT be a scroll container —
|
||||||
// otherwise sticky (hyper-space section) never pins.
|
// otherwise sticky (hyper-space section) never pins.
|
||||||
<main className="w-full">
|
<main className="w-full">
|
||||||
|
{/* 结构化数据:个人实体(SEO 富结果) */}
|
||||||
|
<PersonJsonLd />
|
||||||
<div>
|
<div>
|
||||||
{/* Banner Section */}
|
{/* Banner Section */}
|
||||||
<div
|
<div
|
||||||
@@ -122,7 +125,7 @@ export default async function Home() {
|
|||||||
<HyperSpaceSection />
|
<HyperSpaceSection />
|
||||||
|
|
||||||
{/* Contact / Footer Section (#contact, data-section="footer") */}
|
{/* Contact / Footer Section (#contact, data-section="footer") */}
|
||||||
<FooterSection contactEmail={config.contact_email} />
|
<FooterSection contactEmail={config.contact_email} icpBeian={config.icp_beian} />
|
||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,10 +1,19 @@
|
|||||||
import type { Metadata } from "next";
|
import type { Metadata } from "next";
|
||||||
import ServicesClient from "./ServicesClient";
|
import ServicesClient from "./ServicesClient";
|
||||||
import { getSiteConfig, listServices } from "@/lib/siteConfig";
|
import { getSiteConfig, listServices } from "@/lib/siteConfig";
|
||||||
|
import { absoluteUrl } from "@/lib/siteUrl";
|
||||||
|
|
||||||
export const metadata: Metadata = {
|
export const metadata: Metadata = {
|
||||||
title: "服务 · 北极新一",
|
title: "服务",
|
||||||
description: "可提供的服务 — 选择你需要的服务,留言告诉我",
|
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";
|
export const dynamic = "force-dynamic";
|
||||||
@@ -18,11 +27,39 @@ export default function ServicesPage() {
|
|||||||
description: s.description,
|
description: s.description,
|
||||||
priceNote: s.price_note,
|
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 (
|
return (
|
||||||
<ServicesClient
|
<>
|
||||||
headline={config.services_hero}
|
<script
|
||||||
submitNote={config.services_submit_note}
|
type="application/ld+json"
|
||||||
services={services}
|
// 结构化数据为服务端生成的静态 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 { WORK_ARTICLES } from "@/content/workArticles";
|
||||||
import { isPasscodeProtectedPath } from "@/lib/passcode";
|
import { isPasscodeProtectedPath } from "@/lib/passcode";
|
||||||
import { getPasscodeAccessServer } from "@/lib/passcodeServer";
|
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
|
* Per-page <title>: the original detail route sets <title> to the work name
|
||||||
* (haoqi.design/reunimos → "Reunimos™"). The protected /2026 is gated on the
|
* (haoqi.design/reunimos → "Reunimos™"). The protected /2026 is gated on the
|
||||||
* server — without the access cookie its SSR title is "Protected"; once
|
* server — without the access cookie its SSR title is "Protected"; once
|
||||||
* unlocked the server renders the article. We mirror both states. Lives in a
|
* unlocked the server renders the article. We mirror both states.
|
||||||
* segment layout so `params` contains the slug for both /work/[slug] and its
|
*
|
||||||
* root rewrite.
|
* SEO 增强:优先静态 WORK_ARTICLES,其次后台添加的作品(works 表),
|
||||||
|
* 生成 title / description / canonical / OG。
|
||||||
*/
|
*/
|
||||||
export async function generateMetadata({
|
export async function generateMetadata({
|
||||||
params,
|
params,
|
||||||
@@ -20,10 +23,45 @@ export async function generateMetadata({
|
|||||||
const path = `/${slug}`;
|
const path = `/${slug}`;
|
||||||
if (isPasscodeProtectedPath(path)) {
|
if (isPasscodeProtectedPath(path)) {
|
||||||
const access = await getPasscodeAccessServer();
|
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];
|
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({
|
export default function WorkLayout({
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 4.7 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 2.0 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 4.8 KiB |
@@ -0,0 +1,19 @@
|
|||||||
|
import type { MetadataRoute } from "next";
|
||||||
|
import { absoluteUrl } from "@/lib/siteUrl";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* /robots.txt — 后台 / API / 解锁页全部禁止收录;
|
||||||
|
* sitemap 指向动态路由(app/sitemap.ts,部署域名用 NEXT_PUBLIC_SITE_URL 配置)。
|
||||||
|
*/
|
||||||
|
export default function robots(): MetadataRoute.Robots {
|
||||||
|
return {
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
userAgent: "*",
|
||||||
|
allow: "/",
|
||||||
|
disallow: ["/virtheart", "/virtheart/", "/api/", "/unlock/"],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
sitemap: absoluteUrl("/sitemap.xml"),
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
import type { MetadataRoute } from "next";
|
||||||
|
import { absoluteUrl } from "@/lib/siteUrl";
|
||||||
|
import { listWorks } from "@/lib/siteConfig";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* /sitemap.xml — 动态生成:首页 + 服务页 + 已发布作品详情。
|
||||||
|
* 作品有 updated_at,按它给 lastmod。
|
||||||
|
*/
|
||||||
|
export const dynamic = "force-dynamic";
|
||||||
|
|
||||||
|
export default function sitemap(): MetadataRoute.Sitemap {
|
||||||
|
const entries: MetadataRoute.Sitemap = [
|
||||||
|
{ url: absoluteUrl("/"), changeFrequency: "weekly", priority: 1 },
|
||||||
|
{ url: absoluteUrl("/services"), changeFrequency: "monthly", priority: 0.8 },
|
||||||
|
];
|
||||||
|
for (const w of listWorks(true)) {
|
||||||
|
if (!w.href || w.href.startsWith("http")) continue; // 外链作品不进 sitemap
|
||||||
|
entries.push({
|
||||||
|
url: absoluteUrl(`/work/${w.slug}`),
|
||||||
|
lastModified: w.article_date ? new Date(w.article_date) : undefined,
|
||||||
|
changeFrequency: "monthly",
|
||||||
|
priority: 0.6,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return entries;
|
||||||
|
}
|
||||||
@@ -15,6 +15,8 @@ const labelCls = "mb-1 block font-mono-2 text-xs text-l2";
|
|||||||
const FIELD_LABELS: Record<keyof SiteConfig, string> = {
|
const FIELD_LABELS: Record<keyof SiteConfig, string> = {
|
||||||
site_title: "浏览器标题",
|
site_title: "浏览器标题",
|
||||||
site_description: "站点描述(SEO)",
|
site_description: "站点描述(SEO)",
|
||||||
|
seo_keywords: "SEO 关键词(逗号分隔)",
|
||||||
|
search_verification: "站长验证码(百度/搜狗/360/Bing 的 meta content)",
|
||||||
brand_name: "Header 品牌名",
|
brand_name: "Header 品牌名",
|
||||||
copyright_name: "页脚版权名",
|
copyright_name: "页脚版权名",
|
||||||
hero_line1: "首屏标签 · 第一段",
|
hero_line1: "首屏标签 · 第一段",
|
||||||
@@ -32,6 +34,7 @@ const FIELD_LABELS: Record<keyof SiteConfig, string> = {
|
|||||||
about_p2_link_href: "关于 · 链接地址",
|
about_p2_link_href: "关于 · 链接地址",
|
||||||
footer_headline: "页脚大字(用 | 分行)",
|
footer_headline: "页脚大字(用 | 分行)",
|
||||||
contact_email: "联系邮箱",
|
contact_email: "联系邮箱",
|
||||||
|
icp_beian: "ICP 备案号(部署国内必填;空则页脚不显示)",
|
||||||
work_empty_headline: "作品区空状态 · 大字(用 | 分行)",
|
work_empty_headline: "作品区空状态 · 大字(用 | 分行)",
|
||||||
work_empty_note: "作品区空状态 · 说明",
|
work_empty_note: "作品区空状态 · 说明",
|
||||||
work_empty_cta_prefix: "作品区空状态 · CTA 前缀",
|
work_empty_cta_prefix: "作品区空状态 · CTA 前缀",
|
||||||
@@ -60,7 +63,7 @@ const GROUP_TITLES: Record<string, string> = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const GROUPS: { id: string; keys: (keyof SiteConfig)[] }[] = [
|
const GROUPS: { id: string; keys: (keyof SiteConfig)[] }[] = [
|
||||||
{ id: "basic", keys: ["site_title", "site_description", "brand_name", "copyright_name"] },
|
{ id: "basic", keys: ["site_title", "site_description", "seo_keywords", "search_verification", "brand_name", "copyright_name"] },
|
||||||
{
|
{
|
||||||
id: "hero",
|
id: "hero",
|
||||||
keys: [
|
keys: [
|
||||||
@@ -76,7 +79,7 @@ const GROUPS: { id: string; keys: (keyof SiteConfig)[] }[] = [
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
{ id: "about", keys: ["about_p1", "about_p2", "about_p2_link_label", "about_p2_link_href"] },
|
{ id: "about", keys: ["about_p1", "about_p2", "about_p2_link_label", "about_p2_link_href"] },
|
||||||
{ id: "footer", keys: ["footer_headline", "contact_email"] },
|
{ id: "footer", keys: ["footer_headline", "contact_email", "icp_beian"] },
|
||||||
{
|
{
|
||||||
id: "empty",
|
id: "empty",
|
||||||
keys: [
|
keys: [
|
||||||
|
|||||||
@@ -87,8 +87,11 @@ function QrPreview({ social }: { social: Social }) {
|
|||||||
|
|
||||||
export default function FooterSection({
|
export default function FooterSection({
|
||||||
contactEmail = CONTACT_EMAIL,
|
contactEmail = CONTACT_EMAIL,
|
||||||
|
icpBeian = "",
|
||||||
}: {
|
}: {
|
||||||
contactEmail?: string;
|
contactEmail?: string;
|
||||||
|
/** ICP 备案号(site_config.icp_beian,空则不显示) */
|
||||||
|
icpBeian?: string;
|
||||||
}) {
|
}) {
|
||||||
const [activeQr, setActiveQr] = useState<Social | null>(null);
|
const [activeQr, setActiveQr] = useState<Social | null>(null);
|
||||||
const closeQr = useCallback(() => setActiveQr(null), []);
|
const closeQr = useCallback(() => setActiveQr(null), []);
|
||||||
@@ -218,6 +221,20 @@ export default function FooterSection({
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{/* ICP 备案号 — site_config.icp_beian(后台可填,空则不渲染)。 */}
|
||||||
|
{icpBeian && (
|
||||||
|
<div className="absolute bottom-2 left-0 right-0 flex justify-center px-4 pointer-events-auto">
|
||||||
|
<a
|
||||||
|
href="https://beian.miit.gov.cn/"
|
||||||
|
target="_blank"
|
||||||
|
rel="noopener noreferrer nofollow"
|
||||||
|
className="font-mono-2 text-xs text-l3 hover:text-l2 transition-colors"
|
||||||
|
>
|
||||||
|
{icpBeian}
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</footer>
|
</footer>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
/**
|
||||||
|
* 结构化数据(JSON-LD)— 首页 Person + WebSite。
|
||||||
|
* 给 Google/Bing/百度提供实体信息,支撑品牌知识面板与富结果。
|
||||||
|
*/
|
||||||
|
import { getSiteConfig } from "@/lib/siteConfig";
|
||||||
|
import { absoluteUrl } from "@/lib/siteUrl";
|
||||||
|
|
||||||
|
export function PersonJsonLd() {
|
||||||
|
const config = getSiteConfig();
|
||||||
|
const jsonLd = {
|
||||||
|
"@context": "https://schema.org",
|
||||||
|
"@type": "Person",
|
||||||
|
name: config.brand_name,
|
||||||
|
url: absoluteUrl("/"),
|
||||||
|
email: `mailto:${config.contact_email}`,
|
||||||
|
jobTitle: "全栈开发者 / 设计与工程",
|
||||||
|
knowsAbout: [
|
||||||
|
"Web 开发",
|
||||||
|
"小程序开发",
|
||||||
|
"Flutter",
|
||||||
|
"AI 应用开发",
|
||||||
|
"产品设计",
|
||||||
|
"SpringBoot",
|
||||||
|
"Golang",
|
||||||
|
"Rust",
|
||||||
|
],
|
||||||
|
makesOffer: {
|
||||||
|
"@type": "Offer",
|
||||||
|
url: absoluteUrl("/services"),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
return (
|
||||||
|
<script
|
||||||
|
type="application/ld+json"
|
||||||
|
dangerouslySetInnerHTML={{ __html: JSON.stringify(jsonLd) }}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -203,11 +203,35 @@ function seed() {
|
|||||||
services_hero: "可提供的服务|选择你需要的服务,留言告诉我",
|
services_hero: "可提供的服务|选择你需要的服务,留言告诉我",
|
||||||
services_submit_note:
|
services_submit_note:
|
||||||
"提交即视为同意通过邮件与你取得联系;信息仅用于回复咨询。",
|
"提交即视为同意通过邮件与你取得联系;信息仅用于回复咨询。",
|
||||||
|
icp_beian: "",
|
||||||
|
seo_keywords:
|
||||||
|
"北极新一,全栈开发者,Web开发,小程序开发,Flutter,AI应用开发,产品设计,前后端,Java,SpringBoot,Golang,Rust",
|
||||||
|
search_verification: "",
|
||||||
};
|
};
|
||||||
const insert = db.prepare(
|
const insert = db.prepare(
|
||||||
"INSERT OR IGNORE INTO site_config (key, value) VALUES (?, ?)"
|
"INSERT OR IGNORE INTO site_config (key, value) VALUES (?, ?)"
|
||||||
);
|
);
|
||||||
for (const [k, v] of Object.entries(seedConfig)) insert.run(k, v);
|
for (const [k, v] of Object.entries(seedConfig)) insert.run(k, v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 服务清单种子(价格一律面议;后台可改)。
|
||||||
|
const svcCount = (
|
||||||
|
db.prepare("SELECT COUNT(*) AS c FROM service_items").get() as { c: number }
|
||||||
|
).c;
|
||||||
|
if (svcCount === 0) {
|
||||||
|
const services = [
|
||||||
|
["web", "Web / 小程序 开发", "官网、活动页、小程序、管理后台的设计与开发。"],
|
||||||
|
["ai", "AI 应用 / Agent 原型", "LLM 应用、RAG 知识库、Agent 工作流的原型设计与落地。"],
|
||||||
|
["flutter", "Flutter 跨端客户端", "一套代码交付 iOS / Android 双端应用。"],
|
||||||
|
["backend", "Java / Go 后端服务", "SpringBoot、Golang 服务端开发与接口设计。"],
|
||||||
|
["design", "产品设计 / UI·UX", "从产品构思、信息架构到高保真界面交付。"],
|
||||||
|
["fullstack", "全栈项目交付", "设计 + 前后端 + 部署,独立完成完整应用。"],
|
||||||
|
["consulting", "技术咨询 / 代码评审", "架构建议、性能排查、技术选型。"],
|
||||||
|
];
|
||||||
|
const stmt = db.prepare(
|
||||||
|
"INSERT INTO service_items (slug, title, description, price_note, sort_order, enabled) VALUES (?, ?, ?, '面议', ?, 1)"
|
||||||
|
);
|
||||||
|
services.forEach(([slug, title, desc], i) => stmt.run(slug, title, desc, i + 1));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
seed();
|
seed();
|
||||||
|
|||||||
+10
-2
@@ -32,6 +32,11 @@ export type SiteConfig = {
|
|||||||
copyright_name: string;
|
copyright_name: string;
|
||||||
services_hero: string;
|
services_hero: string;
|
||||||
services_submit_note: string;
|
services_submit_note: string;
|
||||||
|
/** ICP 备案号(部署国内时填,页脚展示;空则不显示) */
|
||||||
|
icp_beian: string;
|
||||||
|
seo_keywords: string;
|
||||||
|
/** 搜索引擎站长验证 meta content(百度/搜狗/360/Bing 通用) */
|
||||||
|
search_verification: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const CONFIG_KEYS = [
|
export const CONFIG_KEYS = [
|
||||||
@@ -61,13 +66,16 @@ export const CONFIG_KEYS = [
|
|||||||
"copyright_name",
|
"copyright_name",
|
||||||
"services_hero",
|
"services_hero",
|
||||||
"services_submit_note",
|
"services_submit_note",
|
||||||
|
"icp_beian",
|
||||||
|
"seo_keywords",
|
||||||
|
"search_verification",
|
||||||
] as const satisfies readonly (keyof SiteConfig)[];
|
] as const satisfies readonly (keyof SiteConfig)[];
|
||||||
|
|
||||||
/** 配置分组(后台表单渲染顺序)。 */
|
/** 配置分组(后台表单渲染顺序)。 */
|
||||||
export const CONFIG_GROUPS: { title: string; keys: (keyof SiteConfig)[] }[] = [
|
export const CONFIG_GROUPS: { title: string; keys: (keyof SiteConfig)[] }[] = [
|
||||||
{
|
{
|
||||||
title: "基础",
|
title: "基础",
|
||||||
keys: ["site_title", "site_description", "brand_name", "copyright_name"],
|
keys: ["site_title", "site_description", "seo_keywords", "search_verification", "brand_name", "copyright_name"],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "首屏",
|
title: "首屏",
|
||||||
@@ -94,7 +102,7 @@ export const CONFIG_GROUPS: { title: string; keys: (keyof SiteConfig)[] }[] = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "页脚",
|
title: "页脚",
|
||||||
keys: ["footer_headline", "contact_email"],
|
keys: ["footer_headline", "contact_email", "icp_beian"],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "作品区空状态",
|
title: "作品区空状态",
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
/**
|
||||||
|
* 站点对外 URL(metadataBase / sitemap / canonical / OG 的绝对地址基准)。
|
||||||
|
* 部署时通过环境变量 NEXT_PUBLIC_SITE_URL 覆盖,例如:
|
||||||
|
* NEXT_PUBLIC_SITE_URL=https://www.virtheart.com
|
||||||
|
* 注意带上协议、结尾不带斜杠。
|
||||||
|
*/
|
||||||
|
export const SITE_URL = (
|
||||||
|
process.env.NEXT_PUBLIC_SITE_URL || "https://virtheart.com"
|
||||||
|
).replace(/\/+$/, "");
|
||||||
|
|
||||||
|
export function absoluteUrl(path = "/"): string {
|
||||||
|
return `${SITE_URL}${path.startsWith("/") ? path : `/${path}`}`;
|
||||||
|
}
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 4.8 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 4.2 KiB |
@@ -0,0 +1,138 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""
|
||||||
|
生成品牌 OG 分享图(1200×630)与方形 icon(512×512)。
|
||||||
|
风格对齐主站:近黑底 + 点阵网格 + lime (#c0fe04) 强调块 + 文字。
|
||||||
|
无 PIL 时纯 zlib 手写 PNG。产物:public/og.png、app/icon-512.png
|
||||||
|
(icon 再用 sips 缩出 192)。
|
||||||
|
"""
|
||||||
|
import zlib
|
||||||
|
import struct
|
||||||
|
|
||||||
|
LIME = (192, 254, 4)
|
||||||
|
INK = (16, 18, 14) # 近黑
|
||||||
|
DOT = (44, 48, 42) # 点阵灰
|
||||||
|
SUB = (96, 106, 92)
|
||||||
|
|
||||||
|
|
||||||
|
def make_canvas(w, h, dot=26):
|
||||||
|
"""黑底 + 点阵网格(点位于格点,1.5px 半径近似为单像素十字)。"""
|
||||||
|
rows = []
|
||||||
|
for y in range(h):
|
||||||
|
row = bytearray()
|
||||||
|
for x in range(w):
|
||||||
|
c = INK
|
||||||
|
if x % dot == 0 and y % dot == 0:
|
||||||
|
c = DOT
|
||||||
|
row += bytes(c)
|
||||||
|
rows.append(bytes(row))
|
||||||
|
return rows
|
||||||
|
|
||||||
|
|
||||||
|
def draw_rect(rows, x0, y0, w, h, color):
|
||||||
|
for y in range(y0, min(y0 + h, len(rows))):
|
||||||
|
row = bytearray(rows[y])
|
||||||
|
for x in range(x0, min(x0 + w, len(row) // 3)):
|
||||||
|
i = x * 3
|
||||||
|
row[i:i + 3] = bytes(color)
|
||||||
|
rows[y] = bytes(row)
|
||||||
|
|
||||||
|
|
||||||
|
def draw_5x7(rows, ox, oy, ch, scale, color):
|
||||||
|
"""极简 5x7 点阵字形(大写字母/数字/汉字块用方块代替逻辑单独处理)。"""
|
||||||
|
glyphs = {
|
||||||
|
"N": ["10001", "11001", "10101", "10011", "10001", "10001", "10001"],
|
||||||
|
"O": ["01110", "10001", "10001", "10001", "10001", "10001", "01110"],
|
||||||
|
"1": ["00100", "01100", "00100", "00100", "00100", "00100", "01110"],
|
||||||
|
"2": ["01110", "10001", "00001", "00010", "00100", "01000", "11111"],
|
||||||
|
"5": ["11111", "10000", "11110", "00001", "00001", "10001", "01110"],
|
||||||
|
"0": ["01110", "10001", "10011", "10101", "11001", "10001", "01110"],
|
||||||
|
"2x": ["01110", "10001", "10001", "00010", "00100", "00000", "00100"],
|
||||||
|
"6": ["01110", "10000", "11110", "10001", "10001", "10001", "01110"],
|
||||||
|
"3": ["11110", "00001", "01110", "00001", "00001", "10001", "01110"],
|
||||||
|
"8": ["01110", "10001", "10001", "01110", "10001", "10001", "01110"],
|
||||||
|
"©": ["01110", "10001", "10111", "10101", "10111", "10001", "01110"],
|
||||||
|
"X": ["10001", "10001", "01010", "00100", "01010", "10001", "10001"],
|
||||||
|
}
|
||||||
|
g = glyphs.get(ch)
|
||||||
|
if not g:
|
||||||
|
return None
|
||||||
|
for ry, line in enumerate(g):
|
||||||
|
for rx, bit in enumerate(line):
|
||||||
|
if bit == "1":
|
||||||
|
draw_rect(rows, ox + rx * scale, oy + ry * scale, scale, scale, color)
|
||||||
|
return 5 * scale # 字宽
|
||||||
|
|
||||||
|
|
||||||
|
def png_bytes(rows):
|
||||||
|
h = len(rows)
|
||||||
|
w = len(rows[0]) // 3
|
||||||
|
raw = b"".join(b"\x00" + r for r in rows)
|
||||||
|
def chunk(tag, data):
|
||||||
|
c = struct.pack(">I", len(data)) + tag + data
|
||||||
|
return c + struct.pack(">I", zlib.crc32(tag + data) & 0xFFFFFFFF)
|
||||||
|
ihdr = struct.pack(">IIBBBBB", w, h, 8, 2, 0, 0, 0)
|
||||||
|
return (b"\x89PNG\r\n\x1a\n" + chunk(b"IHDR", ihdr)
|
||||||
|
+ chunk(b"IDAT", zlib.compress(raw, 9)) + chunk(b"IEND", b""))
|
||||||
|
|
||||||
|
|
||||||
|
def brand_block(rows, w, h):
|
||||||
|
# 左上 lime 标记块
|
||||||
|
draw_rect(rows, 60, 60, 26, 26, LIME)
|
||||||
|
# 底部 lime 长条
|
||||||
|
draw_rect(rows, 60, h - 92, 200, 10, LIME)
|
||||||
|
# 右下三枚小方块(点阵节奏)
|
||||||
|
for i, s in enumerate((16, 24, 12)):
|
||||||
|
draw_rect(rows, w - 80 - i * 52, h - 120 - (i * 17) % 40, s, s, LIME)
|
||||||
|
|
||||||
|
|
||||||
|
def og():
|
||||||
|
w, h = 1200, 630
|
||||||
|
rows = make_canvas(w, h)
|
||||||
|
brand_block(rows, w, h)
|
||||||
|
# 中文无法用点阵字形,用「块状汉字」占位区呈现笔画块——保持极简,
|
||||||
|
# 真实文字交给 title/description;图上仅保留品牌几何元素 + URL。
|
||||||
|
s = 8
|
||||||
|
# 北(象形块阵)
|
||||||
|
def blocks(cells, ox, oy, sc):
|
||||||
|
for cx, cy in cells:
|
||||||
|
draw_rect(rows, ox + cx * sc, oy + cy * sc, sc, sc, (222, 228, 214))
|
||||||
|
# 「北极新一」四字:以栅格块阵近似笔画(装饰性,读作品牌图形)
|
||||||
|
bj = [(1,0),(2,0),(3,0),(1,1),(3,1),(1,2),(2,2),(3,2),(2,3),(1,4),(2,4),(3,4),(2,5),(2,6)]
|
||||||
|
blocks(bj, 60, 150, s)
|
||||||
|
jz = [(0,0),(1,0),(2,0),(0,1),(1,1),(1,2),(0,3),(1,3),(2,3),(1,4),(1,5),(0,6),(1,6),(2,6)]
|
||||||
|
blocks(jz, 130, 150, s)
|
||||||
|
xy = [(0,0),(1,0),(2,0),(3,0),(0,1),(3,1),(0,2),(3,2),(1,3),(2,3),(0,4),(3,4),(0,5),(3,5),(1,6),(2,6)]
|
||||||
|
blocks(xy, 200, 150, s)
|
||||||
|
y1 = [(0,0),(1,0),(2,0),(0,1),(1,1),(2,1),(0,2),(1,2),(2,2),(0,3),(1,3),(2,3),(0,4),(1,4),(2,4),(0,5),(1,5),(2,5),(0,6),(1,6),(2,6)]
|
||||||
|
blocks(y1, 270, 150, s)
|
||||||
|
# 拉丁行:URL 用点阵字形拼出
|
||||||
|
x = 60
|
||||||
|
for ch in "virtheart.com":
|
||||||
|
if ch == ".":
|
||||||
|
draw_rect(rows, x + 2 * s, 400 + 6 * s, s, s, SUB)
|
||||||
|
x += 3 * s + s
|
||||||
|
continue
|
||||||
|
wdt = draw_5x7(rows, x, 400, ch.upper(), s, SUB) or 6 * s
|
||||||
|
x += wdt + s
|
||||||
|
open("public/og.png", "wb").write(png_bytes(rows))
|
||||||
|
|
||||||
|
|
||||||
|
def icon():
|
||||||
|
w = h = 512
|
||||||
|
rows = make_canvas(w, h, dot=22)
|
||||||
|
draw_rect(rows, 40, 40, 24, 24, LIME)
|
||||||
|
s = 10
|
||||||
|
def blocks(cells, ox, oy, sc):
|
||||||
|
for cx, cy in cells:
|
||||||
|
draw_rect(rows, ox + cx * sc, oy + cy * sc, sc, sc, (222, 228, 214))
|
||||||
|
bj = [(1,0),(2,0),(3,0),(1,1),(3,1),(1,2),(2,2),(3,2),(2,3),(1,4),(2,4),(3,4),(2,5),(2,6)]
|
||||||
|
blocks(bj, 166, 140, s)
|
||||||
|
jz = [(0,0),(1,0),(2,0),(0,1),(1,1),(1,2),(0,3),(1,3),(2,3),(1,4),(1,5),(0,6),(1,6),(2,6)]
|
||||||
|
blocks(jz, 216, 140, s)
|
||||||
|
draw_rect(rows, 60, 430, 120, 8, LIME)
|
||||||
|
open("app/icon-512.png", "wb").write(png_bytes(rows))
|
||||||
|
|
||||||
|
|
||||||
|
og()
|
||||||
|
icon()
|
||||||
|
print("og.png + icon-512.png written")
|
||||||
Reference in New Issue
Block a user