为所有工具页面添加 canonical URL、keywords、SoftwareApplication 和 BreadcrumbList 结构化数据,优化标题和描述以包含搜索意图关键词, 更新站点地图日期和优先级,移除无效的 SearchAction,新增 PWA manifest。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
95 lines
2.7 KiB
TypeScript
95 lines
2.7 KiB
TypeScript
import type { Metadata } from "next";
|
|
import { headers } from "next/headers";
|
|
import { SoftwareApplicationStructuredData, BreadcrumbStructuredData } from "@/components/seo/StructuredData";
|
|
|
|
export async function generateMetadata(): Promise<Metadata> {
|
|
const headersList = await headers();
|
|
const acceptLanguage = headersList.get("accept-language") || "";
|
|
const lang = acceptLanguage.includes("zh") ? "zh" : "en";
|
|
|
|
const titles = {
|
|
en: "Image Compression - Optimize PNG, JPEG, WebP Online Free",
|
|
zh: "图片压缩 - 免费在线优化 PNG、JPEG、WebP 图片",
|
|
};
|
|
|
|
const descriptions = {
|
|
en: "Free online image compressor. Optimize PNG, JPEG, WebP, AVIF images without quality loss. Batch processing, format conversion, browser-based with no uploads required.",
|
|
zh: "免费在线图片压缩工具。无损优化 PNG、JPEG、WebP、AVIF 图片。支持批量处理、格式转换,浏览器本地处理无需上传。",
|
|
};
|
|
|
|
const keywords = {
|
|
en: [
|
|
"image compression",
|
|
"image compressor online",
|
|
"compress PNG",
|
|
"compress JPEG",
|
|
"WebP converter",
|
|
"image optimizer",
|
|
"batch image compression",
|
|
"reduce image size",
|
|
"AVIF converter",
|
|
"browser-based",
|
|
],
|
|
zh: [
|
|
"图片压缩",
|
|
"在线图片压缩",
|
|
"PNG压缩",
|
|
"JPEG压缩",
|
|
"WebP转换",
|
|
"图片优化",
|
|
"批量压缩",
|
|
"缩小图片",
|
|
"AVIF转换",
|
|
"浏览器端",
|
|
],
|
|
};
|
|
|
|
const baseUrl = process.env.NEXT_PUBLIC_SITE_URL || "https://kymr.top";
|
|
|
|
return {
|
|
title: titles[lang],
|
|
description: descriptions[lang],
|
|
keywords: keywords[lang],
|
|
alternates: {
|
|
canonical: `${baseUrl}/tools/image-compress`,
|
|
},
|
|
openGraph: {
|
|
title: titles[lang],
|
|
description: descriptions[lang],
|
|
url: `${baseUrl}/tools/image-compress`,
|
|
type: "website",
|
|
},
|
|
twitter: {
|
|
title: titles[lang],
|
|
description: descriptions[lang],
|
|
card: "summary_large_image",
|
|
},
|
|
};
|
|
}
|
|
|
|
export default function ImageCompressLayout({
|
|
children,
|
|
}: {
|
|
children: React.ReactNode;
|
|
}) {
|
|
return (
|
|
<>
|
|
<SoftwareApplicationStructuredData
|
|
name="Image Compressor - KYMR.TOP"
|
|
description="Free online image compression tool. Optimize PNG, JPEG, WebP, AVIF images without quality loss. Browser-based processing with no uploads."
|
|
url="/tools/image-compress"
|
|
category="MultimediaApplication"
|
|
operatingSystem="Any (Browser-based)"
|
|
/>
|
|
<BreadcrumbStructuredData
|
|
items={[
|
|
{ name: "Home", url: "/" },
|
|
{ name: "Tools", url: "/tools" },
|
|
{ name: "Image Compression", url: "/tools/image-compress" },
|
|
]}
|
|
/>
|
|
{children}
|
|
</>
|
|
);
|
|
}
|