浏览代码

测试产品链接重定向

fogwind 2 周之前
父节点
当前提交
36201045c1
共有 2 个文件被更改,包括 9 次插入1 次删除
  1. 8 0
      next.config.ts
  2. 1 1
      src/components/catalog/product/ProductCard.tsx

+ 8 - 0
next.config.ts

@@ -13,6 +13,14 @@ const nextConfig: NextConfig = {
   async headers() {
     return configHeader;
   },
+  async rewrites() {
+    return [
+      {
+        source: '/:slug.html',
+        destination: '/product/:slug',
+      },
+    ];
+  },
   compress: true, 
   experimental: {
     optimizePackageImports: ["lodash", "date-fns"],

+ 1 - 1
src/components/catalog/product/ProductCard.tsx

@@ -37,7 +37,7 @@ export const ProductCard: FC<ProductCardProps> = ({
       className="animate-fadeIn gap-y-4.5 flex flex-col"
     >
       <div className="group relative overflow-hidden rounded-lg">
-        <Link href={`/product/${product.urlKey}`} aria-label={`View ${product.name}`}>
+        <Link href={`/${product.urlKey}.html`} aria-label={`View ${product.name}`}>
           <div className="aspect-[353/283] h-auto truncate rounded-lg">
             <NextImage
               alt={product?.name || "Product image"}