@sgflabs/storefront-core 0.1.18 → 0.1.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/package.json +9 -7
  2. package/src/components/cells/CartDropdown/CartDropdown.tsx +1 -1
  3. package/src/components/cells/CartItemsProducts/CartItemsProducts.tsx +4 -2
  4. package/src/components/cells/UserDropdown/UserDropdown.tsx +2 -2
  5. package/src/components/molecules/CartDropdownItem/CartDropdownItem.tsx +5 -2
  6. package/src/components/molecules/LoginReturnLink/LoginReturnLink.tsx +2 -2
  7. package/src/components/molecules/NativeSelect/NativeSelect.tsx +2 -0
  8. package/src/components/molecules/ProductImage/ProductImage.tsx +1 -1
  9. package/src/components/organisms/CartEmpty/CartEmpty.tsx +1 -1
  10. package/src/components/organisms/Header/Header.tsx +5 -1
  11. package/src/components/organisms/Header/HeaderAccountControls.tsx +6 -5
  12. package/src/components/organisms/Header/HeaderMessages.tsx +14 -0
  13. package/src/components/organisms/ListingToolbar/ListingToolbar.tsx +8 -2
  14. package/src/components/organisms/OrderItems/Item.tsx +5 -2
  15. package/src/components/organisms/ProductCard/ProductCard.tsx +8 -3
  16. package/src/components/organisms/ProductListingHeader/ProductListingHeader.tsx +7 -3
  17. package/src/components/sections/Cart/Cart.tsx +1 -0
  18. package/src/lib/data/bidding.ts +5 -1
  19. package/src/lib/data/seller.ts +17 -2
  20. package/src/lib/helpers/build-product-gallery-slides.ts +25 -0
  21. package/src/lib/helpers/resolve-image-alt.ts +14 -0
  22. package/src/lib/helpers/seo.ts +140 -65
  23. package/src/lib/helpers/store-image-alt.ts +8 -0
  24. package/src/lib/seo/indexing.ts +11 -0
  25. package/src/lib/seo/locale-redirect.ts +11 -0
  26. package/src/lib/seo/seo-config.d.ts +9 -0
  27. package/src/lib/seo/seo-config.js +42 -0
  28. package/src/pages/auth/forgot-password/page.tsx +2 -0
  29. package/src/pages/auth/login/page.tsx +12 -0
  30. package/src/pages/auth/register/page.tsx +11 -0
  31. package/src/pages/invite/page.tsx +2 -2
  32. package/src/pages/main/applications/[handle]/page.tsx +2 -1
  33. package/src/pages/main/auctions/page.tsx +30 -2
  34. package/src/pages/main/best-sellers/page.tsx +2 -1
  35. package/src/pages/main/categories/[category]/page.tsx +4 -2
  36. package/src/pages/main/categories/page.tsx +2 -1
  37. package/src/pages/main/legal/[type]/page.tsx +23 -9
  38. package/src/pages/main/legal/page.tsx +16 -4
  39. package/src/pages/main/sellers/[handle]/page.tsx +23 -2
  40. package/src/pages/main/user/layout.tsx +3 -0
  41. package/src/pages/robots.ts +25 -2
  42. package/src/pages/sitemap.ts +21 -3
  43. package/src/pages/sitemap.xml/route.ts +5 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sgflabs/storefront-core",
3
- "version": "0.1.18",
3
+ "version": "0.1.19",
4
4
  "description": "Shared storefront library consumed as raw TypeScript source by the brand apps.",
5
5
  "license": "PolyForm-Shield-1.0.0",
6
6
  "sideEffects": [
@@ -8,6 +8,7 @@
8
8
  ],
9
9
  "exports": {
10
10
  ".": "./src/index.ts",
11
+ "./lib/seo/seo-config": "./src/lib/seo/seo-config.js",
11
12
  "./*": "./src/*"
12
13
  },
13
14
  "files": [
@@ -55,9 +56,9 @@
55
56
  "devDependencies": {
56
57
  "@sentry/nextjs": "^10.63.0",
57
58
  "@sgflabs/artha-go-sdk": "^0.3.0",
58
- "@sgflabs/gstin": "^0.1.18",
59
- "@sgflabs/page-spec": "^0.1.18",
60
- "@sgflabs/storefront-core-common": "^0.1.18",
59
+ "@sgflabs/gstin": "^0.1.19",
60
+ "@sgflabs/page-spec": "^0.1.19",
61
+ "@sgflabs/storefront-core-common": "^0.1.19",
61
62
  "@testing-library/dom": "^10.4.1",
62
63
  "@testing-library/jest-dom": "^7.0.0",
63
64
  "@testing-library/react": "^16.3.2",
@@ -73,14 +74,15 @@
73
74
  "peerDependencies": {
74
75
  "@sentry/nextjs": "^10.63.0",
75
76
  "@sgflabs/artha-go-sdk": "^0.3.0",
76
- "@sgflabs/gstin": "^0.1.18",
77
- "@sgflabs/page-spec": "^0.1.18",
78
- "@sgflabs/storefront-core-common": "^0.1.18",
77
+ "@sgflabs/gstin": "^0.1.19",
78
+ "@sgflabs/page-spec": "^0.1.19",
79
+ "@sgflabs/storefront-core-common": "^0.1.19",
79
80
  "next": "15.5.27",
80
81
  "react": "^19.3.1",
81
82
  "react-dom": "^19.3.1"
82
83
  },
83
84
  "scripts": {
85
+ "seo:check": "node --disable-warning=MODULE_TYPELESS_PACKAGE_JSON scripts/seo-html-check.ts",
84
86
  "test": "vitest run",
85
87
  "typecheck": "tsc --noEmit"
86
88
  },
@@ -97,9 +97,9 @@ export const CartDropdown = () => {
97
97
  <LocalizedClientLink
98
98
  href="/cart"
99
99
  className="relative"
100
- aria-label="Go to cart"
101
100
  >
102
101
  <CartIcon size={20} />
102
+ <span className="sr-only">Go to cart</span>
103
103
  {Boolean(cartItemsCount) && (
104
104
  <Badge className="absolute -top-2 -right-2 w-4 h-4 p-0">
105
105
  {cartItemsCount}
@@ -12,6 +12,7 @@ import { DeleteCartItemButton } from '../../molecules';
12
12
  import LocalizedClientLink from '../../molecules/LocalizedLink/LocalizedLink';
13
13
  import { UpdateCartItemButton } from '../../molecules/UpdateCartItemButton/UpdateCartItemButton';
14
14
  import { variantOptionTitle } from '../../../lib/helpers/variant-option-title';
15
+ import { resolveStoreImageAlt } from '../../../lib/helpers/store-image-alt';
15
16
  import { filterValidCartItems } from '../../../lib/helpers/filter-valid-cart-items';
16
17
  import { getCartLineItemDisplayAmount } from '../../../lib/helpers/cart-line-item';
17
18
  import { convertToLocale } from '../../../lib/helpers/money';
@@ -74,6 +75,7 @@ export const CartItemsProducts = ({
74
75
  });
75
76
 
76
77
  const lineKey = product.id ?? `cart-line-${index}`
78
+ const imageAlt = resolveStoreImageAlt(product.product?.images?.[0], product.product_title ?? "", 0)
77
79
 
78
80
  // Winner's auction settlement line: shows gross price, the deposit
79
81
  // credit applied, and the net amount actually charged. Only present
@@ -94,7 +96,7 @@ export const CartItemsProducts = ({
94
96
  {product.thumbnail ? (
95
97
  <ProductImage
96
98
  src={product.thumbnail}
97
- alt="Product thumbnail"
99
+ alt={imageAlt}
98
100
  width={100}
99
101
  height={132}
100
102
  className="h-[132px] w-[100px] rounded-xs object-contain"
@@ -102,7 +104,7 @@ export const CartItemsProducts = ({
102
104
  ) : (
103
105
  <Image
104
106
  src={'/images/placeholder.svg'}
105
- alt="Product thumbnail"
107
+ alt={imageAlt}
106
108
  width={50}
107
109
  height={66}
108
110
  className="h-[66px] w-[50px] rounded-xs object-contain opacity-30"
@@ -46,17 +46,17 @@ export const UserDropdown = ({
46
46
  <LocalizedClientLink
47
47
  href="/user"
48
48
  className="relative"
49
- aria-label="Go to user profile"
50
49
  >
51
50
  <ProfileIcon size={20} />
51
+ <span className="sr-only">Go to user profile</span>
52
52
  </LocalizedClientLink>
53
53
  ) : (
54
54
  <LoginReturnLink
55
55
  href="/login"
56
56
  className="relative"
57
- aria-label="Go to user profile"
58
57
  >
59
58
  <ProfileIcon size={20} />
59
+ <span className="sr-only">Go to user profile</span>
60
60
  </LoginReturnLink>
61
61
  )}
62
62
  <Dropdown show={open}>
@@ -10,6 +10,8 @@ import { useMeasurement } from "../../providers/Measurement/MeasurementProvider"
10
10
  import { HttpTypes } from "@medusajs/types"
11
11
  import Image from "next/image"
12
12
 
13
+ import { resolveStoreImageAlt } from "../../../lib/helpers/store-image-alt"
14
+
13
15
  import { ProductImage } from "../ProductImage/ProductImage"
14
16
 
15
17
  export const CartDropdownItem = ({
@@ -20,6 +22,7 @@ export const CartDropdownItem = ({
20
22
  currency_code: string
21
23
  }) => {
22
24
  const { system } = useMeasurement()
25
+ const imageAlt = resolveStoreImageAlt(item.product?.images?.[0], item.product_title ?? "", 0)
23
26
  const original_total = convertToLocale({
24
27
  amount: (item.compare_at_unit_price || 0) * item.quantity,
25
28
  currency_code,
@@ -36,7 +39,7 @@ export const CartDropdownItem = ({
36
39
  {item.thumbnail ? (
37
40
  <ProductImage
38
41
  src={item.thumbnail}
39
- alt={item.product_title || ""}
42
+ alt={imageAlt}
40
43
  width={80}
41
44
  height={90}
42
45
  className="w-[80px] h-[90px] object-cover rounded-xs"
@@ -45,7 +48,7 @@ export const CartDropdownItem = ({
45
48
  ) : (
46
49
  <Image
47
50
  src={"/images/placeholder.svg"}
48
- alt="Product thumbnail"
51
+ alt={imageAlt}
49
52
  width={50}
50
53
  height={66}
51
54
  className="rounded-xs w-[50px] h-[66px] object-contain opacity-30"
@@ -63,7 +63,7 @@ function LoginReturnLinkInner({
63
63
  )
64
64
 
65
65
  return (
66
- <LocalizedClientLink href={hrefWithRedirect} onClick={handleClick} {...props}>
66
+ <LocalizedClientLink href={hrefWithRedirect} onClick={handleClick} rel="nofollow" {...props}>
67
67
  {children}
68
68
  </LocalizedClientLink>
69
69
  )
@@ -84,7 +84,7 @@ export function LoginReturnLink(props: LoginReturnLinkProps) {
84
84
  return (
85
85
  <Suspense
86
86
  fallback={
87
- <LocalizedClientLink href={fallbackHref} className={className} {...rest}>
87
+ <LocalizedClientLink href={fallbackHref} className={className} rel="nofollow" {...rest}>
88
88
  {children}
89
89
  </LocalizedClientLink>
90
90
  }
@@ -53,6 +53,8 @@ const NativeSelect = forwardRef<HTMLSelectElement, NativeSelectProps>(
53
53
  ref={innerRef}
54
54
  defaultValue={defaultValue}
55
55
  {...props}
56
+ // An id or aria-labelledby means the caller labels it; aria-label would override that.
57
+ aria-label={props["aria-label"] ?? (props.id || props["aria-labelledby"] ? undefined : placeholder)}
56
58
  className="appearance-none flex-1 bg-transparent border-none px-4 py-2.5 transition-colors duration-150 outline-none "
57
59
  >
58
60
  <option disabled value="">
@@ -95,7 +95,7 @@ export function ProductImage(
95
95
  return (
96
96
  <Image
97
97
  {...rest}
98
- alt={alt}
98
+ alt={alt ?? placeholderText ?? "Product image"}
99
99
  src={imgSrc}
100
100
  width={width}
101
101
  height={height}
@@ -5,7 +5,7 @@ export function CartEmpty() {
5
5
  return (
6
6
  <div className="col-span-12 pt-4 py-6 flex justify-center" data-testid="cart-empty">
7
7
  <div className="w-[466px] flex flex-col">
8
- <h2 className="text-primary heading-lg text-center">SHOPPING CART</h2>
8
+ <h1 className="text-primary heading-lg text-center">SHOPPING CART</h1>
9
9
  <p className="mt-2 text-lg text-secondary text-center">
10
10
  Your shopping cart is currently empty
11
11
  </p>
@@ -21,12 +21,14 @@ import { HeaderSearch } from "./HeaderSearch"
21
21
  import { BrowsePanel, BrowsePanelProvider, BrowseTrigger } from "../BrowsePanel/BrowsePanel"
22
22
  import { VendorHeaderDropdown } from "../VendorHeaderDropdown/VendorHeaderDropdown"
23
23
 
24
- export const Header = async ({ locale, logo, actions, hideVendors = false }: {
24
+ export const Header = async ({ locale, logo, actions, siteName = "Home", hideVendors = false }: {
25
25
  locale: string
26
26
  /** Single-vendor storefronts: skip the Vendors dropdown and its fetch. */
27
27
  hideVendors?: boolean
28
28
  /** Brand mark, rendered by the caller — Logo differs per brand app. */
29
29
  logo?: ReactNode
30
+ /** Names the home link for assistive tech and crawlers; the logo mark is often an image with empty alt. */
31
+ siteName?: string
30
32
  /** Optional brand call-to-action for the desktop row, placed after Auctions. */
31
33
  actions?: ReactNode
32
34
  }) => {
@@ -105,6 +107,7 @@ export const Header = async ({ locale, logo, actions, hideVendors = false }: {
105
107
  <LocalizedClientLink
106
108
  href="/"
107
109
  data-testid="header-logo-link"
110
+ aria-label={siteName}
108
111
  className="flex-shrink-0 text-primary hover:opacity-80"
109
112
  >
110
113
  {logo}
@@ -167,6 +170,7 @@ export const Header = async ({ locale, logo, actions, hideVendors = false }: {
167
170
  <LocalizedClientLink
168
171
  href="/"
169
172
  data-testid="header-logo-link-mobile"
173
+ aria-label={siteName}
170
174
  className="flex-shrink-0 text-primary hover:opacity-80"
171
175
  >
172
176
  {logo}
@@ -1,16 +1,17 @@
1
1
  "use client"
2
2
 
3
- import { Session } from "@talkjs/react"
3
+ import dynamic from "next/dynamic"
4
4
 
5
5
  import { Badge } from "../../atoms/Badge/Badge"
6
6
  import LocalizedClientLink from "../../molecules/LocalizedLink/LocalizedLink"
7
- import { MessageButton } from "../../molecules/MessageButton/MessageButton"
8
7
  import { UserDropdown } from "../../cells/UserDropdown/UserDropdown"
9
8
  import { HeartIcon } from "../../../icons"
10
9
  import { useCustomerSession } from "../../../hooks/useCustomerSession"
11
10
 
12
11
  const TALKJS_APP_ID = process.env.NEXT_PUBLIC_TALKJS_APP_ID || ""
13
12
 
13
+ const HeaderMessages = dynamic(() => import("./HeaderMessages"), { ssr: false })
14
+
14
15
  export const HeaderAccountControls = ({ locale }: { locale: string }) => {
15
16
  const session = useCustomerSession(locale)
16
17
  // Match ProductCard: undefined = still loading, distinct from logged-out.
@@ -48,9 +49,9 @@ export const HeaderAccountControls = ({ locale }: { locale: string }) => {
48
49
  }
49
50
 
50
51
  return (
51
- <Session appId={TALKJS_APP_ID} userId={user.id}>
52
- <MessageButton />
52
+ <>
53
+ <HeaderMessages appId={TALKJS_APP_ID} userId={user.id} />
53
54
  {accountControls}
54
- </Session>
55
+ </>
55
56
  )
56
57
  }
@@ -0,0 +1,14 @@
1
+ "use client"
2
+
3
+ import { Session } from "@talkjs/react"
4
+
5
+ import { MessageButton } from "../../molecules/MessageButton/MessageButton"
6
+
7
+ /** Kept in its own module so the TalkJS SDK stays out of the header bundle until a signed-in user needs it. */
8
+ export default function HeaderMessages({ appId, userId }: { appId: string; userId: string }) {
9
+ return (
10
+ <Session appId={appId} userId={userId}>
11
+ <MessageButton />
12
+ </Session>
13
+ )
14
+ }
@@ -1,5 +1,7 @@
1
1
  "use client"
2
2
 
3
+ import { useId } from "react"
4
+
3
5
  import useUpdateSearchParams from "../../../hooks/useUpdateSearchParams"
4
6
 
5
7
  /**
@@ -27,6 +29,8 @@ export const ListingToolbar = <TSort extends string>({
27
29
  sortOptions?: ReadonlyArray<{ value: TSort; label: string }>
28
30
  currentSort?: TSort
29
31
  }) => {
32
+ const displayId = useId()
33
+ const sortId = useId()
30
34
  const updateSearchParams = useUpdateSearchParams()
31
35
  const updateParam = (key: string, value: string) =>
32
36
  updateSearchParams(key, value, { resetPage: true })
@@ -48,11 +52,12 @@ export const ListingToolbar = <TSort extends string>({
48
52
 
49
53
  <div className="flex flex-wrap items-center gap-3">
50
54
  <div className="flex items-center gap-2">
51
- <span className="text-sm text-neutral-600 whitespace-nowrap">Display:</span>
55
+ <label htmlFor={displayId} className="text-sm text-neutral-600 whitespace-nowrap">Display:</label>
52
56
  <select
53
57
  value={limit}
54
58
  onChange={(e) => updateParam("limit", e.target.value)}
55
59
  className="text-sm border border-neutral-200 rounded-md px-2 py-1.5 bg-white text-neutral-700 focus:outline-none focus:ring-1 focus:ring-primary"
60
+ id={displayId}
56
61
  data-testid="listing-toolbar-display-select"
57
62
  >
58
63
  {limitOptions.map((n) => (
@@ -65,11 +70,12 @@ export const ListingToolbar = <TSort extends string>({
65
70
 
66
71
  {sortOptions && (
67
72
  <div className="flex items-center gap-2">
68
- <span className="text-sm text-neutral-600 whitespace-nowrap">Sort by:</span>
73
+ <label htmlFor={sortId} className="text-sm text-neutral-600 whitespace-nowrap">Sort by:</label>
69
74
  <select
70
75
  value={currentSort}
71
76
  onChange={(e) => updateParam("sort", e.target.value)}
72
77
  className="text-sm border border-neutral-200 rounded-md px-2 py-1.5 bg-white text-neutral-700 focus:outline-none focus:ring-1 focus:ring-primary"
78
+ id={sortId}
73
79
  data-testid="listing-toolbar-sort-select"
74
80
  >
75
81
  {sortOptions.map(({ label, value }) => (
@@ -8,6 +8,8 @@ import { useMeasurement } from "../../providers/Measurement/MeasurementProvider"
8
8
  import { HttpTypes } from "@medusajs/types"
9
9
  import Image from "next/image"
10
10
 
11
+ import { resolveStoreImageAlt } from "../../../lib/helpers/store-image-alt"
12
+
11
13
  import { ProductImage } from "../../molecules/ProductImage/ProductImage"
12
14
  export const Item = ({
13
15
  item,
@@ -17,6 +19,7 @@ export const Item = ({
17
19
  currencyCode: string
18
20
  }) => {
19
21
  const { system } = useMeasurement()
22
+ const imageAlt = resolveStoreImageAlt(item.product?.images?.[0], item.product_title ?? "", 0)
20
23
  // Order line items carry the variant relation (see `*items.variant` in the
21
24
  // orders fetch fields, matching CartDropdownItem's cart line item pattern)
22
25
  // — options come along with it, so the display can convert/format exactly
@@ -45,7 +48,7 @@ export const Item = ({
45
48
  {item.thumbnail ? (
46
49
  <ProductImage
47
50
  src={item.thumbnail}
48
- alt="Product thumbnail"
51
+ alt={imageAlt}
49
52
  width={100}
50
53
  height={132}
51
54
  className="rounded-xs w-[100px] h-[132px] object-contain"
@@ -53,7 +56,7 @@ export const Item = ({
53
56
  ) : (
54
57
  <Image
55
58
  src={"/images/placeholder.svg"}
56
- alt="Product thumbnail"
59
+ alt={imageAlt}
57
60
  width={50}
58
61
  height={66}
59
62
  className="rounded-xs w-[50px] h-[66px] object-contain opacity-30"
@@ -21,7 +21,7 @@ import { certificationLabel } from "../../../lib/helpers/certification-label"
21
21
  import { UnitPriceDisplay } from "../../molecules/UnitPriceDisplay/UnitPriceDisplay"
22
22
  import LocalizedClientLink from "../../molecules/LocalizedLink/LocalizedLink"
23
23
  import { VegNonVegIndicator } from "../../atoms/VegNonVegIndicator/VegNonVegIndicator"
24
- import { productPlaceholderImageUrl } from "../../../lib/helpers/placeholder-image"
24
+ import { resolveStoreImageAlt } from "../../../lib/helpers/store-image-alt"
25
25
  import { getVegNonVegStatus } from "../../../lib/helpers/veg-non-veg"
26
26
  import { useCartContext } from "../../providers"
27
27
  import { toast } from "../../../lib/helpers/toast"
@@ -273,8 +273,13 @@ export const ProductCard = ({
273
273
  (product as { seller?: { name?: string | null } }).seller?.name ?? null
274
274
  const trimmedImage = typeof primaryImage === "string" ? primaryImage.trim() : ""
275
275
  const isPlaceholder = trimmedImage.length === 0 || trimmedImage === "/images/placeholder.svg"
276
- const imageSrc = isPlaceholder ? productPlaceholderImageUrl(productName) : trimmedImage
277
- const imageAlt = vendorName ? `${productName} by ${vendorName}` : productName
276
+ // A local file: the third-party placeholder host is only for the client-side load-error fallback.
277
+ const imageSrc = isPlaceholder ? "/images/placeholder.svg" : trimmedImage
278
+ const imageAlt = resolveStoreImageAlt(
279
+ (product as { images?: { metadata?: Record<string, unknown> | null }[] }).images?.[0],
280
+ vendorName ? `${productName} by ${vendorName}` : productName,
281
+ 0
282
+ )
278
283
  const handle = product.handle ?? ""
279
284
 
280
285
  const showSampleButton = hasAnyPrice && Boolean(sampleVariant)
@@ -2,7 +2,7 @@
2
2
 
3
3
  import { SellerCartToggle } from '../../molecules';
4
4
  import { useSearchParams } from 'next/navigation';
5
- import { type ReactNode } from 'react';
5
+ import { type ReactNode, useId } from 'react';
6
6
  import { cn } from '../../../lib/utils';
7
7
  import useUpdateSearchParams from '../../../hooks/useUpdateSearchParams';
8
8
 
@@ -37,6 +37,8 @@ export const ProductListingHeader = ({
37
37
  */
38
38
  heading?: string
39
39
  }) => {
40
+ const displayId = useId();
41
+ const sortId = useId();
40
42
  const searchParams = useSearchParams();
41
43
  const updateSearchParams = useUpdateSearchParams();
42
44
 
@@ -87,11 +89,12 @@ export const ProductListingHeader = ({
87
89
  <div className="flex items-center gap-3 flex-wrap">
88
90
  {/* Display per page */}
89
91
  <div className="flex items-center gap-2">
90
- <span className="text-sm text-neutral-600 whitespace-nowrap">Display:</span>
92
+ <label htmlFor={displayId} className="text-sm text-neutral-600 whitespace-nowrap">Display:</label>
91
93
  <select
92
94
  value={limit}
93
95
  onChange={(e) => updateParam('limit', e.target.value)}
94
96
  className="text-sm border border-neutral-200 rounded-md px-2 py-1.5 bg-white text-neutral-700 focus:outline-none focus:ring-1 focus:ring-primary"
97
+ id={displayId}
95
98
  data-testid="product-listing-display-select"
96
99
  >
97
100
  {DISPLAY_OPTIONS.map((n) => (
@@ -102,11 +105,12 @@ export const ProductListingHeader = ({
102
105
 
103
106
  {/* Sort */}
104
107
  <div className="flex items-center gap-2">
105
- <span className="text-sm text-neutral-600 whitespace-nowrap">Sort by:</span>
108
+ <label htmlFor={sortId} className="text-sm text-neutral-600 whitespace-nowrap">Sort by:</label>
106
109
  <select
107
110
  value={currentSort}
108
111
  onChange={(e) => updateParam('sort', e.target.value)}
109
112
  className="text-sm border border-neutral-200 rounded-md px-2 py-1.5 bg-white text-neutral-700 focus:outline-none focus:ring-1 focus:ring-primary"
113
+ id={sortId}
110
114
  data-testid="product-listing-sort-select"
111
115
  >
112
116
  {SORT_OPTIONS.map(({ label, value }) => (
@@ -64,6 +64,7 @@ export const Cart = ({
64
64
 
65
65
  return (
66
66
  <>
67
+ <h1 className="sr-only">Shopping cart</h1>
67
68
  <div className="col-span-12 lg:col-span-6">
68
69
  {handoffBanner}
69
70
  {cartItems}
@@ -57,7 +57,9 @@ export const listAuctions = async ({
57
57
  pageParam?: number
58
58
  limit?: number
59
59
  filters?: AuctionFilters
60
- }): Promise<{
60
+ },
61
+ { throwOnError = false }: { throwOnError?: boolean } = {}
62
+ ): Promise<{
61
63
  auctions: Auction[]
62
64
  count: number
63
65
  nextPage: number | null
@@ -72,6 +74,8 @@ export const listAuctions = async ({
72
74
  })
73
75
 
74
76
  if (!response.ok || !response.data) {
77
+ // Metadata passes throwOnError so a 5xx is not mistaken for an empty listing and noindexed.
78
+ if (throwOnError) throw new Error(`Failed to list auctions (HTTP ${response.status})`)
75
79
  return { auctions: [], count: 0, nextPage: null }
76
80
  }
77
81
 
@@ -163,9 +163,12 @@ const MAX_LIST_SELLERS_PAGES = 10
163
163
  export const listSellers = async ({
164
164
  limit = LIST_SELLERS_PAGE_SIZE,
165
165
  offset = 0,
166
+ isStatic = false,
166
167
  }: {
167
168
  limit?: number
168
169
  offset?: number
170
+ /** Read with the env key (`getStaticSdk`, never `headers()`) so a static/ISR route such as the sitemap stays static. */
171
+ isStatic?: boolean
169
172
  } = {}): Promise<{
170
173
  sellers: StoreSellerNavItem[]
171
174
  count: number
@@ -173,7 +176,7 @@ export const listSellers = async ({
173
176
  rawPageLength: number
174
177
  }> => {
175
178
  try {
176
- const data = await (await getSdk()).client.fetch<{
179
+ const data = await (await (isStatic ? getStaticSdk() : getSdk())).client.fetch<{
177
180
  sellers?: StoreSellerNavItem[]
178
181
  count?: number
179
182
  }>("/store/seller", {
@@ -216,7 +219,9 @@ export const listSellers = async ({
216
219
  * (still exposed as rawPageLength). Client-side `has_published_products`
217
220
  * filtering remains as defense in depth.
218
221
  */
219
- export const listAllSellersForNav = async (): Promise<StoreSellerNavItem[]> => {
222
+ export const listAllSellersForNav = async ({
223
+ isStatic = false,
224
+ }: { isStatic?: boolean } = {}): Promise<StoreSellerNavItem[]> => {
220
225
  const sellers: StoreSellerNavItem[] = []
221
226
  let seen = 0
222
227
  for (let page = 0; page < MAX_LIST_SELLERS_PAGES; page++) {
@@ -224,6 +229,7 @@ export const listAllSellersForNav = async (): Promise<StoreSellerNavItem[]> => {
224
229
  const batch = await listSellers({
225
230
  limit: LIST_SELLERS_PAGE_SIZE,
226
231
  offset,
232
+ isStatic,
227
233
  })
228
234
  sellers.push(...batch.sellers)
229
235
  seen += batch.rawPageLength
@@ -234,6 +240,15 @@ export const listAllSellersForNav = async (): Promise<StoreSellerNavItem[]> => {
234
240
  return sellers
235
241
  }
236
242
 
243
+ /**
244
+ * Handles of public sellers for the sitemap: the nav listing read with the env key, so the sitemap
245
+ * shard stays static/ISR-compatible. `listSellers` already requires a handle, ACTIVE status and
246
+ * bounds the paging; a failure is reported there and yields no seller URLs rather than failing the
247
+ * sitemap build.
248
+ */
249
+ export const listSellerHandlesForSitemap = async (): Promise<string[]> =>
250
+ (await listAllSellersForNav({ isStatic: true })).map((seller) => seller.handle)
251
+
237
252
  /**
238
253
  * Description of the marketplace's single seller (edited in the vendor panel),
239
254
  * used as the footer tagline on single-vendor storefronts. Cached and read with
@@ -1 +1,26 @@
1
+ import type { HttpTypes } from "@medusajs/types"
2
+ import {
3
+ buildProductGallerySlides as buildSharedGallerySlides,
4
+ type ProductGallerySlide,
5
+ } from "@sgflabs/storefront-core-common/lib/helpers/build-product-gallery-slides"
6
+
7
+ import { resolveStoreImageAlt } from "./store-image-alt"
8
+
1
9
  export * from "@sgflabs/storefront-core-common/lib/helpers/build-product-gallery-slides"
10
+
11
+ const LOCAL_PLACEHOLDER = "/images/placeholder.svg"
12
+
13
+ /**
14
+ * The shared slides, with two crawler-facing differences: an image's own `metadata.alt` wins over
15
+ * the derived text, and a product with no media gets the local placeholder instead of a
16
+ * third-party host in the server-rendered HTML.
17
+ */
18
+ export function buildProductGallerySlides(product: HttpTypes.StoreProduct): ProductGallerySlide[] {
19
+ return buildSharedGallerySlides(product).map((slide) => {
20
+ if (slide.id === `${product.id}-placeholder`) {
21
+ return { ...slide, url: LOCAL_PLACEHOLDER }
22
+ }
23
+ const image = product.images?.find((candidate) => candidate.id === slide.id)
24
+ return image?.metadata?.alt ? { ...slide, alt: resolveStoreImageAlt(image, product.title ?? "", 0) } : slide
25
+ })
26
+ }
@@ -0,0 +1,14 @@
1
+ const FALLBACK_ALT = "Product image"
2
+
3
+ /** Alt text for a product image: its own metadata alt, else derived from the product title. */
4
+ export const resolveImageAlt = (
5
+ image: { metadata?: { alt?: unknown } } | null | undefined,
6
+ productTitle: string,
7
+ index: number
8
+ ) => {
9
+ const metadataAlt = image?.metadata?.alt
10
+ if (typeof metadataAlt === "string" && metadataAlt.trim()) return metadataAlt.trim()
11
+ const title = productTitle.trim()
12
+ if (!title) return FALLBACK_ALT
13
+ return index > 0 ? `${title} - image ${index + 1}` : title
14
+ }