Added breadcrumbs on PDP - #107
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
WalkthroughThis change threads Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
src/components/products/ProductCard.tsx (1)
59-59: Encodecategory_idwhen building product links.Direct interpolation can break URLs when values contain reserved characters. Build the query string with
URLSearchParamsfor safe encoding.🔧 Suggested fix
- href={`${basePath}/products/${product.slug}${categoryId ? `?category_id=${categoryId}` : ""}`} + href={`${basePath}/products/${product.slug}${ + categoryId + ? `?${new URLSearchParams({ category_id: categoryId }).toString()}` + : "" + }`}🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/components/products/ProductCard.tsx` at line 59, The product link currently interpolates categoryId directly into the href in ProductCard (href={`${basePath}/products/${product.slug}${categoryId ? `?category_id=${categoryId}` : ""}`), which can break for reserved/unsafe characters; change the link construction to build the query string with URLSearchParams (or new URLSearchParams().append('category_id', categoryId)) and append the encoded params only when non-empty so basePath, product.slug, and category_id are correctly encoded.src/lib/data/cached.ts (1)
6-12: Split product expand fields for PDP vs metadata to avoid over-fetch.
PRODUCT_PAGE_EXPANDis shared by both PDP and metadata, but metadata generation does not consumecategories.ancestors(seesrc/lib/metadata/product.ts:18+). This adds unnecessary payload and latency to metadata requests.♻️ Suggested refactor
-export const PRODUCT_PAGE_EXPAND = [ +export const PRODUCT_SHARED_EXPAND = [ "variants", "media", "option_types", "custom_fields", +]; + +export const PRODUCT_PAGE_EXPAND = [ + ...PRODUCT_SHARED_EXPAND, "categories.ancestors", ];Then switch metadata to
PRODUCT_SHARED_EXPAND(or a dedicated metadata expand constant).🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/lib/data/cached.ts` around lines 6 - 12, PRODUCT_PAGE_EXPAND currently includes "categories.ancestors" and is used both for PDP and metadata generation, causing extra payload; split the expands into two constants (e.g., PRODUCT_SHARED_EXPAND containing "variants","media","option_types","custom_fields" and PRODUCT_PAGE_EXPAND adding "categories.ancestors"), then update the metadata code that currently imports/uses PRODUCT_PAGE_EXPAND (see product metadata code referencing product expands) to use PRODUCT_SHARED_EXPAND (or a dedicated metadata expand constant) so metadata requests no longer fetch categories.ancestors.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/components/products/ProductCard.tsx`:
- Line 59: The product link currently interpolates categoryId directly into the
href in ProductCard (href={`${basePath}/products/${product.slug}${categoryId ?
`?category_id=${categoryId}` : ""}`), which can break for reserved/unsafe
characters; change the link construction to build the query string with
URLSearchParams (or new URLSearchParams().append('category_id', categoryId)) and
append the encoded params only when non-empty so basePath, product.slug, and
category_id are correctly encoded.
In `@src/lib/data/cached.ts`:
- Around line 6-12: PRODUCT_PAGE_EXPAND currently includes
"categories.ancestors" and is used both for PDP and metadata generation, causing
extra payload; split the expands into two constants (e.g., PRODUCT_SHARED_EXPAND
containing "variants","media","option_types","custom_fields" and
PRODUCT_PAGE_EXPAND adding "categories.ancestors"), then update the metadata
code that currently imports/uses PRODUCT_PAGE_EXPAND (see product metadata code
referencing product expands) to use PRODUCT_SHARED_EXPAND (or a dedicated
metadata expand constant) so metadata requests no longer fetch
categories.ancestors.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 3c60d909-efc9-4636-903e-7480ea972215
📒 Files selected for processing (8)
src/app/[country]/[locale]/(storefront)/c/[...permalink]/CategoryProductsContent.tsxsrc/app/[country]/[locale]/(storefront)/products/[slug]/page.tsxsrc/components/navigation/Breadcrumbs.tsxsrc/components/products/ProductCard.tsxsrc/components/products/ProductGrid.tsxsrc/components/products/ProductListingLayout.tsxsrc/lib/data/cached.tssrc/lib/seo.ts
Summary by CodeRabbit