@tokenoftrust/storefront-runner 2.2.36 → 2.2.37

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.
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Where a product page's "Shipping & returns policy" link points. The policy is tenant
3
+ * content, so the link targets a page the tenant actually has: the Shopify-convention
4
+ * `/pages/shipping-returns` first, then a top-level `/shipping-returns`, each as either a
5
+ * structured page or a raw HTML page. No such page means no link, never a dangling one.
6
+ */
7
+ import type { ContentProvider } from "../storyblok/provider.js";
8
+
9
+ export const SHIPPING_POLICY_SLUGS = ["pages/shipping-returns", "shipping-returns"] as const;
10
+
11
+ export async function shippingPolicyPath(
12
+ content: Pick<ContentProvider, "getPage" | "getPageHtml">,
13
+ ): Promise<string | null> {
14
+ for (const slug of SHIPPING_POLICY_SLUGS) {
15
+ if ((await content.getPage(slug)) || (await content.getPageHtml(slug))) return `/${slug}`;
16
+ }
17
+ return null;
18
+ }
@@ -41,6 +41,7 @@ import { truncate } from "@/lib/format";
41
41
  import { productLd, breadcrumbLd, reviewLd } from "@/lib/jsonld";
42
42
  import { isUsableImageUrl } from "@/lib/placeholder";
43
43
  import { withBase } from "@/lib/basePath";
44
+ import { shippingPolicyPath } from "@/lib/commerce/shippingPolicy";
44
45
  import AppWidgetFrame from "@/components/apps/AppWidgetFrame.astro";
45
46
  import { getRegistryService } from "@/lib/apps/registryAccess.js";
46
47
  import { renderWidgetSlot } from "@/lib/apps/widgets/renderSlot.js";
@@ -169,6 +170,7 @@ const chrome = await Astro.locals.content.getChrome();
169
170
  const productCategory = product.product_type || mf("compliance", "product_category");
170
171
  const disclaimer =
171
172
  (productCategory && chrome.disclaimers?.[productCategory]) || chrome.disclaimer;
173
+ const shippingPolicyHref = await shippingPolicyPath(Astro.locals.content);
172
174
 
173
175
  // Full review content (migrated from the store's reviews app). The aggregate
174
176
  // (reviewAvg/reviewCount above) comes from metafields; this is the per-review text.
@@ -460,14 +462,16 @@ const jsonLd = [productJsonLd, breadcrumbLd(crumbs, canonicalBase)];
460
462
  Delivery times, rates, and returns are covered in our policy —
461
463
  including the adult-signature (21+) requirement on every order.
462
464
  </p>
463
- <div class="mt-3">
464
- <a
465
- href={withBase(basePath, "/shipping-returns")}
466
- class="link-accent link-accent--cta font-medium"
467
- >
468
- Shipping &amp; returns policy
469
- </a>
470
- </div>
465
+ {shippingPolicyHref && (
466
+ <div class="mt-3">
467
+ <a
468
+ href={withBase(basePath, shippingPolicyHref)}
469
+ class="link-accent link-accent--cta font-medium"
470
+ >
471
+ Shipping &amp; returns policy
472
+ </a>
473
+ </div>
474
+ )}
471
475
  </div>
472
476
  </details>
473
477
  </div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tokenoftrust/storefront-runner",
3
- "version": "2.2.36",
3
+ "version": "2.2.37",
4
4
  "license": "SEE LICENSE IN LICENSE",
5
5
  "description": "World-shareable storefront runner: multi-tenant renderer on Astro/Cloudflare. No control plane.",
6
6
  "packageManager": "pnpm@11.9.0",