@tokenoftrust/storefront-runner 1.3.2
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.
- package/LICENSE +58 -0
- package/README.md +42 -0
- package/apps/storefront/astro.config.mjs +66 -0
- package/apps/storefront/dev-plugins/dev-loop-state.mjs +147 -0
- package/apps/storefront/dev-plugins/tenant-hot-reload.mjs +238 -0
- package/apps/storefront/env.d.ts +162 -0
- package/apps/storefront/migrations/0000_baseline.sql +54 -0
- package/apps/storefront/migrations/0001_products_fts.sql +9 -0
- package/apps/storefront/migrations/README.md +54 -0
- package/apps/storefront/migrations/meta/0000_snapshot.json +347 -0
- package/apps/storefront/migrations/meta/0001_snapshot.json +347 -0
- package/apps/storefront/migrations/meta/_journal.json +20 -0
- package/apps/storefront/package.json +42 -0
- package/apps/storefront/public/brand/northwind-logo-dark.svg +4 -0
- package/apps/storefront/public/brand/northwind-logo-light.svg +4 -0
- package/apps/storefront/public/brand/northwind-og.svg +13 -0
- package/apps/storefront/public/favicon.svg +5 -0
- package/apps/storefront/public/js/dashboard-team.js +147 -0
- package/apps/storefront/public/js/dashboard-vendor-search.js +115 -0
- package/apps/storefront/public/shared/commerce-chrome.css +369 -0
- package/apps/storefront/src/components/Badge.astro +34 -0
- package/apps/storefront/src/components/Breadcrumbs.astro +45 -0
- package/apps/storefront/src/components/CollectionCard.astro +56 -0
- package/apps/storefront/src/components/EmptyState.astro +55 -0
- package/apps/storefront/src/components/Img.astro +68 -0
- package/apps/storefront/src/components/ProductCard.astro +228 -0
- package/apps/storefront/src/components/Section.astro +39 -0
- package/apps/storefront/src/components/Seo.astro +70 -0
- package/apps/storefront/src/components/WidgetFrame.astro +34 -0
- package/apps/storefront/src/components/admin/AdminAIWorkflowsTab.astro +531 -0
- package/apps/storefront/src/components/admin/AdminCustomersTab.astro +597 -0
- package/apps/storefront/src/components/admin/AdminFoxyCartSettingsPanel.astro +227 -0
- package/apps/storefront/src/components/admin/AdminFulfillmentTab.astro +465 -0
- package/apps/storefront/src/components/admin/AdminProductsTab.astro +901 -0
- package/apps/storefront/src/components/admin/AdminReportingTab.astro +435 -0
- package/apps/storefront/src/components/admin/AdminSettingsTab.astro +782 -0
- package/apps/storefront/src/components/admin/orders/OrdersWorkspace.astro +1223 -0
- package/apps/storefront/src/components/auth/AuthBadge.astro +44 -0
- package/apps/storefront/src/components/chrome/AnnouncementBar.astro +108 -0
- package/apps/storefront/src/components/chrome/MegaMenu.astro +26 -0
- package/apps/storefront/src/components/chrome/NavDropdown.astro +201 -0
- package/apps/storefront/src/components/chrome/SiteFooter.astro +201 -0
- package/apps/storefront/src/components/chrome/SiteHeader.astro +234 -0
- package/apps/storefront/src/components/chrome/UtilityNav.astro +79 -0
- package/apps/storefront/src/components/commerce/ArticleCard.astro +242 -0
- package/apps/storefront/src/components/commerce/BrandGrid.astro +175 -0
- package/apps/storefront/src/components/commerce/FoxyLoader.astro +23 -0
- package/apps/storefront/src/components/commerce/FoxySidecartStyles.astro +61 -0
- package/apps/storefront/src/components/commerce/PriceDisplay.astro +91 -0
- package/apps/storefront/src/components/commerce/ProductCarousel.astro +197 -0
- package/apps/storefront/src/components/commerce/ProductGrid.astro +75 -0
- package/apps/storefront/src/components/commerce/RatingStars.astro +58 -0
- package/apps/storefront/src/components/commerce/ReviewList.astro +54 -0
- package/apps/storefront/src/components/commerce/ReviewSummary.astro +44 -0
- package/apps/storefront/src/components/commerce/TagFilterCloud.astro +149 -0
- package/apps/storefront/src/components/compliance/AdultSignatureNotice.astro +37 -0
- package/apps/storefront/src/components/compliance/ComplianceNotice.astro +99 -0
- package/apps/storefront/src/components/compliance/ExciseTaxNotice.astro +45 -0
- package/apps/storefront/src/components/compliance/NicotineWarning.astro +33 -0
- package/apps/storefront/src/components/compliance/PactActNotice.astro +35 -0
- package/apps/storefront/src/components/compliance/Prop65Warning.astro +80 -0
- package/apps/storefront/src/components/compliance/PurchaseLimitNotice.astro +38 -0
- package/apps/storefront/src/components/compliance/ShippingRestrictionNotice.astro +35 -0
- package/apps/storefront/src/components/compliance/StateEligibilityNotice.astro +53 -0
- package/apps/storefront/src/components/home/Hero.astro +164 -0
- package/apps/storefront/src/components/islands/AgeGate.tsx +109 -0
- package/apps/storefront/src/components/islands/ImageGallery.tsx +237 -0
- package/apps/storefront/src/components/islands/IsolatedAgeGate.tsx +73 -0
- package/apps/storefront/src/components/islands/MobileNav.tsx +239 -0
- package/apps/storefront/src/components/islands/QuickView.tsx +138 -0
- package/apps/storefront/src/components/islands/RecentlyViewed.tsx +122 -0
- package/apps/storefront/src/components/islands/SavedList.tsx +99 -0
- package/apps/storefront/src/components/islands/SearchTypeahead.tsx +248 -0
- package/apps/storefront/src/components/islands/VariantSelector.tsx +375 -0
- package/apps/storefront/src/components/marketing/CardGrid.astro +72 -0
- package/apps/storefront/src/components/marketing/CodeSample.astro +20 -0
- package/apps/storefront/src/components/marketing/CtaBand.astro +24 -0
- package/apps/storefront/src/components/marketing/Faq.astro +37 -0
- package/apps/storefront/src/components/marketing/Integrations.astro +63 -0
- package/apps/storefront/src/components/marketing/MarketingBlocks.astro +53 -0
- package/apps/storefront/src/components/marketing/MarketingCtas.astro +48 -0
- package/apps/storefront/src/components/marketing/MarketingHero.astro +72 -0
- package/apps/storefront/src/components/marketing/ProofStrip.astro +37 -0
- package/apps/storefront/src/components/marketing/SplitCompare.astro +53 -0
- package/apps/storefront/src/components/marketing/Steps.astro +36 -0
- package/apps/storefront/src/components/marketing/Testimonials.astro +38 -0
- package/apps/storefront/src/components/marketing/TrustBar.astro +22 -0
- package/apps/storefront/src/components/membership/IllustrativeLabel.astro +56 -0
- package/apps/storefront/src/components/membership/TierCards.astro +164 -0
- package/apps/storefront/src/components/membership/TierComparisonTable.astro +148 -0
- package/apps/storefront/src/components/plp/ActiveFilters.astro +79 -0
- package/apps/storefront/src/components/plp/FacetSidebar.astro +199 -0
- package/apps/storefront/src/components/plp/Pagination.astro +99 -0
- package/apps/storefront/src/components/plp/SortSelect.astro +64 -0
- package/apps/storefront/src/components/style-guide/StyleGuideNav.astro +95 -0
- package/apps/storefront/src/components/subscription/HowItWorksSteps.astro +67 -0
- package/apps/storefront/src/components/subscription/ManageSubscriptionEntry.astro +67 -0
- package/apps/storefront/src/components/subscription/SavingsExplainer.astro +101 -0
- package/apps/storefront/src/config/adminTargetTenant.ts +28 -0
- package/apps/storefront/src/config/devTenantSeed.ts +78 -0
- package/apps/storefront/src/config/devTenants.ts +16 -0
- package/apps/storefront/src/config/kvTenantResolver.ts +87 -0
- package/apps/storefront/src/config/resolver.ts +102 -0
- package/apps/storefront/src/config/tenants.ts +87 -0
- package/apps/storefront/src/layouts/Layout.astro +368 -0
- package/apps/storefront/src/lib/admin/README.md +122 -0
- package/apps/storefront/src/lib/admin/ai/approvalMode.ts +21 -0
- package/apps/storefront/src/lib/admin/ai/askEnvelope.ts +48 -0
- package/apps/storefront/src/lib/admin/ai/audit.ts +14 -0
- package/apps/storefront/src/lib/admin/ai/index.ts +6 -0
- package/apps/storefront/src/lib/admin/ai/operationalRuns.ts +155 -0
- package/apps/storefront/src/lib/admin/ai/recommendation.ts +20 -0
- package/apps/storefront/src/lib/admin/checkoutStyleInput.ts +172 -0
- package/apps/storefront/src/lib/admin/checkoutStyleTarget.ts +65 -0
- package/apps/storefront/src/lib/admin/envelope.ts +10 -0
- package/apps/storefront/src/lib/admin/evidence/evidenceReference.ts +32 -0
- package/apps/storefront/src/lib/admin/memoizeByEnvelope.ts +27 -0
- package/apps/storefront/src/lib/admin/orderClient.ts +146 -0
- package/apps/storefront/src/lib/admin/seed.ts +54 -0
- package/apps/storefront/src/lib/admin/services/mock/aiWorkflows.ts +59 -0
- package/apps/storefront/src/lib/admin/services/mock/customers.ts +86 -0
- package/apps/storefront/src/lib/admin/services/mock/evidence.ts +99 -0
- package/apps/storefront/src/lib/admin/services/mock/foxyCartSettings.ts +78 -0
- package/apps/storefront/src/lib/admin/services/mock/fulfillment.ts +62 -0
- package/apps/storefront/src/lib/admin/services/mock/index.ts +12 -0
- package/apps/storefront/src/lib/admin/services/mock/orders.ts +184 -0
- package/apps/storefront/src/lib/admin/services/mock/products.ts +105 -0
- package/apps/storefront/src/lib/admin/services/mock/reporting.ts +51 -0
- package/apps/storefront/src/lib/admin/services/mock/settings.ts +70 -0
- package/apps/storefront/src/lib/admin/services/mock/tenants.ts +29 -0
- package/apps/storefront/src/lib/admin/services/orders.ts +300 -0
- package/apps/storefront/src/lib/admin/viewmodels/aiWorkflows.ts +67 -0
- package/apps/storefront/src/lib/admin/viewmodels/customers.ts +56 -0
- package/apps/storefront/src/lib/admin/viewmodels/fulfillment.ts +49 -0
- package/apps/storefront/src/lib/admin/viewmodels/orders.ts +92 -0
- package/apps/storefront/src/lib/admin/viewmodels/products.ts +74 -0
- package/apps/storefront/src/lib/admin/viewmodels/reporting.ts +34 -0
- package/apps/storefront/src/lib/admin/viewmodels/settings.ts +64 -0
- package/apps/storefront/src/lib/adminTenantEnvelope.ts +90 -0
- package/apps/storefront/src/lib/analytics/index.ts +47 -0
- package/apps/storefront/src/lib/auth/brokerAssertion.ts +136 -0
- package/apps/storefront/src/lib/auth/devAuth.ts +90 -0
- package/apps/storefront/src/lib/auth/gatePage.ts +81 -0
- package/apps/storefront/src/lib/auth/identityToken.ts +341 -0
- package/apps/storefront/src/lib/auth/loginGate.ts +119 -0
- package/apps/storefront/src/lib/auth/route.ts +146 -0
- package/apps/storefront/src/lib/auth/session.ts +203 -0
- package/apps/storefront/src/lib/auth/totAccessClient.ts +503 -0
- package/apps/storefront/src/lib/basePath.ts +41 -0
- package/apps/storefront/src/lib/cfImage.ts +55 -0
- package/apps/storefront/src/lib/chrome/model.ts +244 -0
- package/apps/storefront/src/lib/chrome/parseConfig.ts +34 -0
- package/apps/storefront/src/lib/colors.ts +97 -0
- package/apps/storefront/src/lib/commerce/foxyCartSettings.ts +253 -0
- package/apps/storefront/src/lib/content-edit/applyDiff.ts +91 -0
- package/apps/storefront/src/lib/content-edit/client.ts +230 -0
- package/apps/storefront/src/lib/content-edit/index.ts +14 -0
- package/apps/storefront/src/lib/content-edit/route.ts +25 -0
- package/apps/storefront/src/lib/content-edit/types.ts +19 -0
- package/apps/storefront/src/lib/cspStaticHashes.ts +24 -0
- package/apps/storefront/src/lib/d1/catalog.ts +366 -0
- package/apps/storefront/src/lib/dashboard/staffAdmission.ts +43 -0
- package/apps/storefront/src/lib/dashboard/staffVendorAccess.ts +449 -0
- package/apps/storefront/src/lib/dashboard/tenantSelection.ts +136 -0
- package/apps/storefront/src/lib/dashboard/vendorQuery.ts +61 -0
- package/apps/storefront/src/lib/demoGate.ts +113 -0
- package/apps/storefront/src/lib/dev/activityIngestToken.ts +78 -0
- package/apps/storefront/src/lib/dev/activityStore.ts +72 -0
- package/apps/storefront/src/lib/dev/ai-widget-client.js +308 -0
- package/apps/storefront/src/lib/dev/apiBase.ts +14 -0
- package/apps/storefront/src/lib/dev/cliSignInCode.ts +155 -0
- package/apps/storefront/src/lib/dev/devDraft.ts +133 -0
- package/apps/storefront/src/lib/dev/hostedCockpit.ts +169 -0
- package/apps/storefront/src/lib/dev/livePreview.ts +77 -0
- package/apps/storefront/src/lib/dev/runtimeStore.ts +120 -0
- package/apps/storefront/src/lib/dev/storeStatus.ts +142 -0
- package/apps/storefront/src/lib/diag/redact.ts +20 -0
- package/apps/storefront/src/lib/edgeCache.ts +128 -0
- package/apps/storefront/src/lib/email/magicLinkInviteEmail.ts +62 -0
- package/apps/storefront/src/lib/env.ts +60 -0
- package/apps/storefront/src/lib/fixtures/sampleProducts.ts +130 -0
- package/apps/storefront/src/lib/format.ts +38 -0
- package/apps/storefront/src/lib/foxyCommerce.ts +49 -0
- package/apps/storefront/src/lib/imageAttrs.ts +55 -0
- package/apps/storefront/src/lib/jsonld.ts +166 -0
- package/apps/storefront/src/lib/maintenance.ts +71 -0
- package/apps/storefront/src/lib/membership/model.ts +97 -0
- package/apps/storefront/src/lib/memoryKv.ts +32 -0
- package/apps/storefront/src/lib/messaging/messagesClient.ts +143 -0
- package/apps/storefront/src/lib/placeholder.ts +99 -0
- package/apps/storefront/src/lib/previewReload.ts +125 -0
- package/apps/storefront/src/lib/priceBuckets.ts +33 -0
- package/apps/storefront/src/lib/rawChrome.ts +505 -0
- package/apps/storefront/src/lib/rawMarketingHtml.ts +136 -0
- package/apps/storefront/src/lib/search/index.ts +74 -0
- package/apps/storefront/src/lib/sections.ts +129 -0
- package/apps/storefront/src/lib/securityHeaders.ts +31 -0
- package/apps/storefront/src/lib/storyblok/content-model.ts +289 -0
- package/apps/storefront/src/lib/storyblok/provider.ts +607 -0
- package/apps/storefront/src/lib/subscription/model.ts +68 -0
- package/apps/storefront/src/lib/tenantRouting.ts +91 -0
- package/apps/storefront/src/lib/tot/ToTClient.ts +177 -0
- package/apps/storefront/src/lib/tot/d1Client.ts +62 -0
- package/apps/storefront/src/lib/tot/query.ts +249 -0
- package/apps/storefront/src/lib/tot/totClientInterface.ts +30 -0
- package/apps/storefront/src/lib/url.ts +142 -0
- package/apps/storefront/src/lib/wishlist.ts +63 -0
- package/apps/storefront/src/middleware/index.ts +455 -0
- package/apps/storefront/src/pages/404.astro +61 -0
- package/apps/storefront/src/pages/[...slug].astro +90 -0
- package/apps/storefront/src/pages/admin.astro +1675 -0
- package/apps/storefront/src/pages/api/admin/orders/[id].ts +53 -0
- package/apps/storefront/src/pages/api/admin/orders.ts +71 -0
- package/apps/storefront/src/pages/api/auth/logout.ts +21 -0
- package/apps/storefront/src/pages/api/auth/magic-exchange.ts +107 -0
- package/apps/storefront/src/pages/api/auth/send.ts +85 -0
- package/apps/storefront/src/pages/api/auth/verify.ts +135 -0
- package/apps/storefront/src/pages/api/cache-purge.ts +44 -0
- package/apps/storefront/src/pages/api/checkout-style.css.ts +43 -0
- package/apps/storefront/src/pages/api/cli/policy.ts +70 -0
- package/apps/storefront/src/pages/api/content-edit/ai-edit.ts +164 -0
- package/apps/storefront/src/pages/api/csp-report.ts +25 -0
- package/apps/storefront/src/pages/api/dashboard/enter-vendor.ts +124 -0
- package/apps/storefront/src/pages/api/dashboard/vendor-search.ts +120 -0
- package/apps/storefront/src/pages/api/dev/activity.ts +124 -0
- package/apps/storefront/src/pages/api/dev/cli-signin-code.ts +73 -0
- package/apps/storefront/src/pages/api/dev/diff.ts +68 -0
- package/apps/storefront/src/pages/api/dev/file.ts +57 -0
- package/apps/storefront/src/pages/api/dev/locate.ts +125 -0
- package/apps/storefront/src/pages/api/dev/publish.ts +128 -0
- package/apps/storefront/src/pages/api/dev/tree.ts +70 -0
- package/apps/storefront/src/pages/api/dev/write.ts +116 -0
- package/apps/storefront/src/pages/api/newsletter.ts +104 -0
- package/apps/storefront/src/pages/api/request-access.ts +172 -0
- package/apps/storefront/src/pages/auth/login.astro +149 -0
- package/apps/storefront/src/pages/auth/magic.astro +105 -0
- package/apps/storefront/src/pages/capabilities.astro +292 -0
- package/apps/storefront/src/pages/collections/[handle].astro +177 -0
- package/apps/storefront/src/pages/collections/index.astro +59 -0
- package/apps/storefront/src/pages/dashboard/[appDomain]/index.astro +100 -0
- package/apps/storefront/src/pages/dashboard/[appDomain]/team.astro +154 -0
- package/apps/storefront/src/pages/dashboard/index.astro +160 -0
- package/apps/storefront/src/pages/index.astro +290 -0
- package/apps/storefront/src/pages/llms.txt.ts +92 -0
- package/apps/storefront/src/pages/products/[handle].astro +402 -0
- package/apps/storefront/src/pages/robots.txt.ts +24 -0
- package/apps/storefront/src/pages/saved.astro +35 -0
- package/apps/storefront/src/pages/search.astro +150 -0
- package/apps/storefront/src/pages/sitemap.xml.ts +78 -0
- package/apps/storefront/src/pages/style-guide/[tenant]/[theme].astro +1280 -0
- package/apps/storefront/src/pages/style-guide/[tenant]/chrome/[theme].astro +229 -0
- package/apps/storefront/src/pages/style-guide/[tenant]/guide/[theme].astro +144 -0
- package/apps/storefront/src/pages/style-guide/[tenant]/index.astro +116 -0
- package/apps/storefront/src/pages/style-guide/index.astro +98 -0
- package/apps/storefront/src/pages/tenants/[id]/[...path].ts +57 -0
- package/apps/storefront/src/styles/global.css +292 -0
- package/apps/storefront/src/themes/reference.ts +68 -0
- package/apps/storefront/src/themes/schema.ts +111 -0
- package/apps/storefront/src/themes/tenants/index.ts +51 -0
- package/apps/storefront/tsconfig.json +16 -0
- package/apps/storefront/vitest.config.ts +22 -0
- package/package.json +26 -0
- package/packages/public-runtime/LICENSE +58 -0
- package/packages/public-runtime/package.json +22 -0
- package/packages/public-runtime/src/binary-path.ts +68 -0
- package/packages/public-runtime/src/capabilities.ts +89 -0
- package/packages/public-runtime/src/catalog-api.ts +81 -0
- package/packages/public-runtime/src/catalog-d1.ts +192 -0
- package/packages/public-runtime/src/checkout-style-publish.ts +200 -0
- package/packages/public-runtime/src/checkout-style.ts +375 -0
- package/packages/public-runtime/src/csp.ts +109 -0
- package/packages/public-runtime/src/customization-preview.ts +197 -0
- package/packages/public-runtime/src/customization-reconcile.ts +63 -0
- package/packages/public-runtime/src/customization-runtime.ts +157 -0
- package/packages/public-runtime/src/customization-scripts.ts +64 -0
- package/packages/public-runtime/src/customization-versioning.ts +95 -0
- package/packages/public-runtime/src/foxy-orders.ts +136 -0
- package/packages/public-runtime/src/foxy.ts +196 -0
- package/packages/public-runtime/src/hot-standby-readiness.ts +140 -0
- package/packages/public-runtime/src/index.ts +34 -0
- package/packages/public-runtime/src/product.ts +159 -0
- package/packages/public-runtime/src/search.ts +45 -0
- package/packages/public-runtime/src/tenant-assets.ts +444 -0
- package/packages/public-runtime/src/tenant.ts +384 -0
- package/packages/public-runtime/tsconfig.json +8 -0
- package/packages/public-runtime/vitest.config.ts +8 -0
- package/pnpm-workspace.yaml +7 -0
- package/scripts/build/copy-tenant-assets.mjs +69 -0
- package/scripts/dev/ai-edit.mjs +183 -0
- package/scripts/dev/checkout-watch.mjs +116 -0
- package/scripts/dev/file-browser.mjs +159 -0
- package/scripts/dev/file-writer.mjs +141 -0
- package/scripts/dev/git-status.mjs +171 -0
- package/scripts/dev/locate-handler.mjs +163 -0
- package/scripts/dev/locate.mjs +112 -0
- package/scripts/dev/port-check.mjs +48 -0
- package/scripts/dev/safe-path.mjs +109 -0
- package/scripts/dev/shot.mjs +46 -0
- package/scripts/dev/tenant-source-root.mjs +76 -0
- package/scripts/dev/unified-diff.mjs +81 -0
- package/scripts/tot-dev.mjs +376 -0
- package/tenants/README.md +14 -0
- package/tenants/home/content/chrome.json +7 -0
- package/tenants/home/content/home.html +58 -0
- package/tenants/home/content/home.json +11 -0
- package/tenants/home/public/js/storefront.js +210 -0
- package/tenants/home/public/logo-wordmark.png +0 -0
- package/tenants/home/public/pages/storefront.css +212 -0
- package/tenants/home/theme.json +6 -0
- package/tsconfig.base.json +20 -0
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* /search — dual-purpose route (brief §5 Search).
|
|
4
|
+
*
|
|
5
|
+
* 1. `?format=json` — returns `{ products: TypeaheadDoc[] }` for the header
|
|
6
|
+
* typeahead island. Search runs through the ToTClient (D1 FTS5 when bound, else
|
|
7
|
+
* a Fuse index over the snapshot) over ACTIVE products only (drafts never surface).
|
|
8
|
+
* 2. Otherwise — the full results page: a no-JS <form>, the echoed query, a
|
|
9
|
+
* result count, and a product grid. Results pages are `noindex` (standard
|
|
10
|
+
* practice — thin, parameterized, duplicative).
|
|
11
|
+
*/
|
|
12
|
+
import Layout from "@/layouts/Layout.astro";
|
|
13
|
+
import Breadcrumbs from "@/components/Breadcrumbs.astro";
|
|
14
|
+
import ProductCard from "@/components/ProductCard.astro";
|
|
15
|
+
import EmptyState from "@/components/EmptyState.astro";
|
|
16
|
+
import Section from "@/components/Section.astro";
|
|
17
|
+
import { toTypeaheadDoc } from "@/lib/search";
|
|
18
|
+
import { breadcrumbLd } from "@/lib/jsonld";
|
|
19
|
+
import { withBase } from "@/lib/basePath";
|
|
20
|
+
|
|
21
|
+
const { tenant, tot, canonicalBase, basePath } = Astro.locals;
|
|
22
|
+
// Commerce-only route (page + typeahead JSON): off for marketing tenants.
|
|
23
|
+
if (!Astro.locals.features.productSearch) return new Response(null, { status: 404 });
|
|
24
|
+
const url = new URL(Astro.request.url);
|
|
25
|
+
const q = (url.searchParams.get("q") ?? "").trim();
|
|
26
|
+
const isJson = url.searchParams.get("format") === "json";
|
|
27
|
+
|
|
28
|
+
// Search goes through the ToTClient: D1 FTS5 when a D1 binding is wired, else a
|
|
29
|
+
// Fuse index over the bundled snapshot (FixtureToTClient). It returns full
|
|
30
|
+
// products, so the HTML grid renders directly and the typeahead just projects to
|
|
31
|
+
// the compact shape. See epics/edge-read-replica.md.
|
|
32
|
+
|
|
33
|
+
// --- JSON path: powers the header typeahead island. Must return BEFORE render.
|
|
34
|
+
if (isJson) {
|
|
35
|
+
const docs = (await tot.search(q, 8)).map(toTypeaheadDoc);
|
|
36
|
+
return new Response(JSON.stringify({ products: docs }), {
|
|
37
|
+
headers: { "content-type": "application/json" },
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// --- HTML path.
|
|
42
|
+
const results = q ? await tot.search(q, 24) : [];
|
|
43
|
+
const featured = q ? [] : await tot.getFeatured(8);
|
|
44
|
+
|
|
45
|
+
const crumbs = [
|
|
46
|
+
{ label: tenant.displayName, href: "/" },
|
|
47
|
+
{ label: "Search", href: "/search" },
|
|
48
|
+
];
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
<Layout
|
|
52
|
+
title={q ? `Search: ${q}` : "Search"}
|
|
53
|
+
description={`Search the ${tenant.displayName} catalog.`}
|
|
54
|
+
path="/search"
|
|
55
|
+
noindex={true}
|
|
56
|
+
jsonLd={breadcrumbLd(crumbs, canonicalBase)}
|
|
57
|
+
>
|
|
58
|
+
<div class="container-prose pt-6">
|
|
59
|
+
<Breadcrumbs crumbs={crumbs} />
|
|
60
|
+
</div>
|
|
61
|
+
|
|
62
|
+
{/* Search hero + no-JS form (works without the island). */}
|
|
63
|
+
<header class="container-prose pb-2 pt-8">
|
|
64
|
+
<p class="eyebrow eyebrow--tick mb-3">Search</p>
|
|
65
|
+
<h1 class="display-xl">
|
|
66
|
+
{q ? <>Results for “{q}”</> : "What are you after?"}
|
|
67
|
+
</h1>
|
|
68
|
+
<form
|
|
69
|
+
method="get"
|
|
70
|
+
action={withBase(basePath, "/search")}
|
|
71
|
+
role="search"
|
|
72
|
+
class="mt-7 flex max-w-xl items-center gap-2 rounded-full border border-[var(--color-border)] bg-[var(--color-surface)] px-4 py-2 focus-within:border-[var(--color-primary)]"
|
|
73
|
+
>
|
|
74
|
+
<svg
|
|
75
|
+
width="18"
|
|
76
|
+
height="18"
|
|
77
|
+
viewBox="0 0 24 24"
|
|
78
|
+
fill="none"
|
|
79
|
+
stroke="currentColor"
|
|
80
|
+
stroke-width="2"
|
|
81
|
+
stroke-linecap="round"
|
|
82
|
+
aria-hidden="true"
|
|
83
|
+
class="shrink-0 text-[var(--color-muted)]"
|
|
84
|
+
>
|
|
85
|
+
<circle cx="11" cy="11" r="7"></circle>
|
|
86
|
+
<line x1="21" y1="21" x2="16.65" y2="16.65"></line>
|
|
87
|
+
</svg>
|
|
88
|
+
<label class="sr-only" for="search-input">Search products</label>
|
|
89
|
+
<input
|
|
90
|
+
id="search-input"
|
|
91
|
+
type="search"
|
|
92
|
+
name="q"
|
|
93
|
+
value={q}
|
|
94
|
+
autocomplete="off"
|
|
95
|
+
placeholder="Search products"
|
|
96
|
+
class="w-full min-w-0 bg-transparent font-body text-text placeholder:text-muted focus:outline-none"
|
|
97
|
+
/>
|
|
98
|
+
<button
|
|
99
|
+
type="submit"
|
|
100
|
+
class="shrink-0 rounded-full bg-[var(--color-primary)] px-5 py-1.5 font-display text-sm font-medium text-[var(--color-primary-contrast)] transition-transform hover:-translate-y-0.5"
|
|
101
|
+
>
|
|
102
|
+
Search
|
|
103
|
+
</button>
|
|
104
|
+
</form>
|
|
105
|
+
{q && (
|
|
106
|
+
<p class="mt-4 text-sm text-[var(--color-muted)]">
|
|
107
|
+
{results.length} {results.length === 1 ? "result" : "results"}
|
|
108
|
+
</p>
|
|
109
|
+
)}
|
|
110
|
+
</header>
|
|
111
|
+
|
|
112
|
+
{q ? (
|
|
113
|
+
results.length === 0 ? (
|
|
114
|
+
<EmptyState
|
|
115
|
+
title={`No matches for “${q}”`}
|
|
116
|
+
body="Nothing in the catalog answers to that — yet. Try a broader word, a category, or browse the full range."
|
|
117
|
+
ctaLabel="Browse collections"
|
|
118
|
+
ctaHref="/collections"
|
|
119
|
+
/>
|
|
120
|
+
) : (
|
|
121
|
+
<section class="bg-[var(--color-bg)] py-[clamp(2rem,5vw,3.5rem)]">
|
|
122
|
+
<div class="container-prose">
|
|
123
|
+
<div class="grid grid-cols-2 gap-5 sm:grid-cols-2 lg:grid-cols-4">
|
|
124
|
+
{results.map((p, i) => (
|
|
125
|
+
<ProductCard product={p} position={i} list="search" />
|
|
126
|
+
))}
|
|
127
|
+
</div>
|
|
128
|
+
</div>
|
|
129
|
+
</section>
|
|
130
|
+
)
|
|
131
|
+
) : (
|
|
132
|
+
<>
|
|
133
|
+
<EmptyState
|
|
134
|
+
title="Start with a word"
|
|
135
|
+
body="Search by name, maker, or material. Or wander through the collections below."
|
|
136
|
+
ctaLabel="Browse collections"
|
|
137
|
+
ctaHref="/collections"
|
|
138
|
+
/>
|
|
139
|
+
{featured.length > 0 && (
|
|
140
|
+
<Section title="While you're here" eyebrow="Featured" tone="surface">
|
|
141
|
+
<div class="grid grid-cols-2 gap-5 lg:grid-cols-4">
|
|
142
|
+
{featured.map((p, i) => (
|
|
143
|
+
<ProductCard product={p} position={i} list="search-featured" />
|
|
144
|
+
))}
|
|
145
|
+
</div>
|
|
146
|
+
</Section>
|
|
147
|
+
)}
|
|
148
|
+
</>
|
|
149
|
+
)}
|
|
150
|
+
</Layout>
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-tenant XML sitemap. Built from the resolved tenant's canonical base +
|
|
3
|
+
* catalog. ACTIVE products only — getAllActiveProducts() excludes the draft
|
|
4
|
+
* canary (`trail-cap`), so drafts never leak into the sitemap. Editorial slugs
|
|
5
|
+
* come from the ContentProvider.
|
|
6
|
+
*/
|
|
7
|
+
import type { APIContext } from "astro";
|
|
8
|
+
|
|
9
|
+
interface SitemapUrl {
|
|
10
|
+
loc: string;
|
|
11
|
+
lastmod?: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** XML-escape text inside a tag (URLs may contain & in query, etc.). */
|
|
15
|
+
function escapeXml(value: string): string {
|
|
16
|
+
return value
|
|
17
|
+
.replace(/&/g, "&")
|
|
18
|
+
.replace(/</g, "<")
|
|
19
|
+
.replace(/>/g, ">")
|
|
20
|
+
.replace(/"/g, """)
|
|
21
|
+
.replace(/'/g, "'");
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export async function GET(context: APIContext): Promise<Response> {
|
|
25
|
+
const { tot, canonicalBase, content, features } = context.locals;
|
|
26
|
+
const base = canonicalBase.replace(/\/$/, "");
|
|
27
|
+
|
|
28
|
+
const urls: SitemapUrl[] = [{ loc: `${base}/` }];
|
|
29
|
+
|
|
30
|
+
// Commerce URLs only for tenants with a catalog sitemap. Marketing tenants
|
|
31
|
+
// emit homepage + content pages, keeping product/collection routes out.
|
|
32
|
+
if (features.commerceSitemap) {
|
|
33
|
+
const [products, collections] = await Promise.all([
|
|
34
|
+
tot.getAllActiveProducts(),
|
|
35
|
+
tot.listCollections(),
|
|
36
|
+
]);
|
|
37
|
+
urls.push({ loc: `${base}/collections` });
|
|
38
|
+
for (const c of collections) {
|
|
39
|
+
urls.push({ loc: `${base}/collections/${c.handle}` });
|
|
40
|
+
}
|
|
41
|
+
for (const p of products) {
|
|
42
|
+
const entry: SitemapUrl = { loc: `${base}/products/${p.handle}` };
|
|
43
|
+
if (p.updated_at) entry.lastmod = p.updated_at;
|
|
44
|
+
urls.push(entry);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Raw tenant-authored marketing subpages (content/<tenant>/pages-html/*.html).
|
|
49
|
+
const rawPageSlugs = await content.listPageHtmlSlugs();
|
|
50
|
+
for (const slug of rawPageSlugs) {
|
|
51
|
+
urls.push({ loc: `${base}/${slug}/` });
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const pages = await content.listPages();
|
|
55
|
+
for (const page of pages) {
|
|
56
|
+
urls.push({ loc: `${base}/${page.slug}` });
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const body = `<?xml version="1.0" encoding="UTF-8"?>
|
|
60
|
+
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
|
61
|
+
${urls
|
|
62
|
+
.map(
|
|
63
|
+
(u) =>
|
|
64
|
+
` <url>\n <loc>${escapeXml(u.loc)}</loc>${
|
|
65
|
+
u.lastmod ? `\n <lastmod>${escapeXml(u.lastmod)}</lastmod>` : ""
|
|
66
|
+
}\n </url>`,
|
|
67
|
+
)
|
|
68
|
+
.join("\n")}
|
|
69
|
+
</urlset>
|
|
70
|
+
`;
|
|
71
|
+
|
|
72
|
+
return new Response(body, {
|
|
73
|
+
headers: {
|
|
74
|
+
"content-type": "application/xml; charset=utf-8",
|
|
75
|
+
"cache-control": "public, max-age=300, s-maxage=3600",
|
|
76
|
+
},
|
|
77
|
+
});
|
|
78
|
+
}
|