feat: 更新产品类型和内容,优化产品展示功能
- 重构产品类型定义,新增desc、models、content字段 - 更新所有语言的产品内容,包括详细规格和化学/机械性能 - 修改产品展示组件,支持MDX内容渲染和模型列表展示 - 调整产品详情页布局,优化信息展示方式 - 更新i18n翻译文件,同步产品名称变更 - 修改默认主题配置为light模式 - 修复公司简介中的格式问题
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import MDXComponents from "@/components/mdx/MDXComponents";
|
||||
import ProductTabsClient from "@/components/ProductTabsClient";
|
||||
import { Locale, LOCALES } from "@/i18n/routing";
|
||||
import { getProducts } from "@/lib/getProducts";
|
||||
@@ -5,7 +6,9 @@ import { constructMetadata } from "@/lib/metadata";
|
||||
import { Product } from "@/types/product";
|
||||
import { Metadata } from "next";
|
||||
import { getTranslations } from "next-intl/server";
|
||||
import { MDXRemote } from "next-mdx-remote-client/rsc";
|
||||
import { notFound } from "next/navigation";
|
||||
import remarkGfm from "remark-gfm"; // 引入表格解析插件
|
||||
|
||||
type Params = {
|
||||
locale: string;
|
||||
@@ -23,7 +26,7 @@ export async function generateMetadata({
|
||||
|
||||
try {
|
||||
const { products }: { products: Product[] } = await getProducts(locale);
|
||||
const product = products.find((product) => product.slug === slug);
|
||||
const product = products.find((product) => product.slug == slug);
|
||||
|
||||
if (!product) {
|
||||
return constructMetadata({
|
||||
@@ -117,8 +120,8 @@ export default async function ProductPage({ params }: { params: Promise<Params>
|
||||
<h1 className="text-xl font-bold mb-3">{product.title || "未命名产品"}</h1>
|
||||
<div className="space-y-2 mb-6">
|
||||
<div>
|
||||
<span className="font-medium">{t("productModel")}:</span>
|
||||
<span>{product.model || "暂无"}</span>
|
||||
<span className="font-medium">{t('productDetail')}:</span>
|
||||
<span>{product.desc || "暂无"}</span>
|
||||
</div>
|
||||
<div>
|
||||
<span className="font-medium">{t("productPlace")}:</span>
|
||||
@@ -155,10 +158,17 @@ export default async function ProductPage({ params }: { params: Promise<Params>
|
||||
|
||||
<ProductTabsClient
|
||||
locale={locale}
|
||||
detail={product.detail}
|
||||
detail={product.desc}
|
||||
models={product.models}
|
||||
spec={product.spec}
|
||||
packaging={product.packaging}
|
||||
/>
|
||||
|
||||
<MDXRemote source={product.content || ""} components={MDXComponents} options={{
|
||||
mdxOptions: {
|
||||
remarkPlugins: [remarkGfm], // 加入表格解析插件
|
||||
},
|
||||
}} />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user