@hszrdm/create-commerce 1.1.0 → 1.3.0

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 (54) hide show
  1. package/package.json +2 -2
  2. package/src/cli.mjs +5 -2
  3. package/templates/backend/.env.example +45 -0
  4. package/templates/backend/package.json +1 -1
  5. package/templates/storefront/README.md +14 -1
  6. package/templates/storefront/src/app/[countryCode]/products/[handle]/page.tsx +43 -9
  7. package/templates/storefront/src/app/account/page.tsx +12 -1
  8. package/templates/storefront/src/app/account/wishlist/page.tsx +9 -0
  9. package/templates/storefront/src/app/blog/[slug]/page.tsx +36 -0
  10. package/templates/storefront/src/app/blog/page.tsx +25 -0
  11. package/templates/storefront/src/app/contact/page.tsx +25 -0
  12. package/templates/storefront/src/app/core-ux.css +244 -0
  13. package/templates/storefront/src/app/customer-capabilities.css +60 -0
  14. package/templates/storefront/src/app/knowledge-base/[slug]/page.tsx +35 -0
  15. package/templates/storefront/src/app/knowledge-base/page.tsx +25 -0
  16. package/templates/storefront/src/app/layout.tsx +40 -12
  17. package/templates/storefront/src/app/newsletter/confirm/page.tsx +19 -0
  18. package/templates/storefront/src/app/newsletter/unsubscribe/page.tsx +19 -0
  19. package/templates/storefront/src/app/pages/[slug]/page.tsx +35 -0
  20. package/templates/storefront/src/app/quote-request/page.tsx +20 -0
  21. package/templates/storefront/src/components/accessibility-preferences.tsx +126 -0
  22. package/templates/storefront/src/components/accessible-dialog.tsx +88 -0
  23. package/templates/storefront/src/components/accessible-dropdown.tsx +98 -0
  24. package/templates/storefront/src/components/account-wishlist.tsx +95 -0
  25. package/templates/storefront/src/components/add-to-cart.tsx +110 -15
  26. package/templates/storefront/src/components/back-to-top.tsx +26 -0
  27. package/templates/storefront/src/components/breadcrumbs.tsx +26 -0
  28. package/templates/storefront/src/components/cart-view.tsx +72 -16
  29. package/templates/storefront/src/components/cms-content.tsx +75 -0
  30. package/templates/storefront/src/components/form-ux.tsx +47 -0
  31. package/templates/storefront/src/components/free-shipping-progress.tsx +35 -0
  32. package/templates/storefront/src/components/lead-form.tsx +203 -0
  33. package/templates/storefront/src/components/newsletter-action.tsx +66 -0
  34. package/templates/storefront/src/components/newsletter-signup.tsx +107 -0
  35. package/templates/storefront/src/components/product-gallery.tsx +64 -0
  36. package/templates/storefront/src/components/product-reviews.tsx +150 -0
  37. package/templates/storefront/src/components/quantity-stepper.tsx +41 -0
  38. package/templates/storefront/src/components/quote-request-form.tsx +212 -0
  39. package/templates/storefront/src/components/share-button.tsx +63 -0
  40. package/templates/storefront/src/components/storefront-header.tsx +72 -18
  41. package/templates/storefront/src/components/tier-progress-hint.tsx +32 -0
  42. package/templates/storefront/src/components/toast-provider.tsx +92 -0
  43. package/templates/storefront/src/components/variant-price-display.tsx +31 -0
  44. package/templates/storefront/src/components/wishlist-button.tsx +88 -0
  45. package/templates/storefront/src/lib/core/account.ts +3 -0
  46. package/templates/storefront/src/lib/core/cms-contract.ts +35 -0
  47. package/templates/storefront/src/lib/core/cms.ts +71 -11
  48. package/templates/storefront/src/lib/core/form-ux.ts +57 -0
  49. package/templates/storefront/src/lib/core/newsletter.ts +53 -0
  50. package/templates/storefront/src/lib/core/reviews.ts +40 -0
  51. package/templates/storefront/src/lib/core/share.ts +57 -0
  52. package/templates/storefront/src/lib/core/wishlist.ts +88 -0
  53. package/templates/storefront/src/lib/storefront-routes.ts +33 -0
  54. package/templates/storefront/src/proxy.ts +25 -28
@@ -0,0 +1,35 @@
1
+ export const CORE_CMS_CONTENT_TYPES = {
2
+ BLOG_POST: "blog_post",
3
+ PAGE: "page",
4
+ KNOWLEDGE_BASE: "knowledge_base",
5
+ } as const
6
+
7
+ export type CoreCmsContentType =
8
+ typeof CORE_CMS_CONTENT_TYPES[keyof typeof CORE_CMS_CONTENT_TYPES]
9
+
10
+ /**
11
+ * Built-in HSZRDM Commerce CMS content types.
12
+ *
13
+ * Projects may still persist and query arbitrary custom content_type strings.
14
+ * This type keeps the built-ins discoverable without restricting extensions.
15
+ */
16
+ export type CmsContentType = CoreCmsContentType | (string & {})
17
+
18
+ export const CORE_CMS_CONTENT_TYPE_OPTIONS = [
19
+ {
20
+ value: CORE_CMS_CONTENT_TYPES.BLOG_POST,
21
+ label: "Blogbejegyzés",
22
+ },
23
+ {
24
+ value: CORE_CMS_CONTENT_TYPES.PAGE,
25
+ label: "Oldal",
26
+ },
27
+ {
28
+ value: CORE_CMS_CONTENT_TYPES.KNOWLEDGE_BASE,
29
+ label: "Tudástár",
30
+ },
31
+ ] as const
32
+
33
+ export function isCoreCmsContentType(value: string): value is CoreCmsContentType {
34
+ return (Object.values(CORE_CMS_CONTENT_TYPES) as string[]).includes(value)
35
+ }
@@ -1,4 +1,17 @@
1
+ import type { Metadata } from "next"
1
2
  import { medusaFetch } from "./client"
3
+ import {
4
+ CORE_CMS_CONTENT_TYPES,
5
+ type CmsContentType,
6
+ } from "./cms-contract"
7
+
8
+ export {
9
+ CORE_CMS_CONTENT_TYPES,
10
+ CORE_CMS_CONTENT_TYPE_OPTIONS,
11
+ isCoreCmsContentType,
12
+ type CoreCmsContentType,
13
+ type CmsContentType,
14
+ } from "./cms-contract"
2
15
 
3
16
  export type CmsTaxonomyTerm = {
4
17
  id: string
@@ -6,20 +19,20 @@ export type CmsTaxonomyTerm = {
6
19
  name: string
7
20
  slug: string
8
21
  description?: string | null
9
- locale: string
22
+ locale: string | null
10
23
  metadata?: Record<string, unknown> | null
11
24
  }
12
25
 
13
26
  export type CmsEntry = {
14
27
  id: string
15
- content_type: string
28
+ content_type: CmsContentType
16
29
  title: string
17
30
  slug: string
18
31
  excerpt?: string | null
19
32
  body?: string | null
20
33
  body_format: "markdown" | "html" | "blocks"
21
34
  blocks?: unknown
22
- locale: string
35
+ locale: string | null
23
36
  featured_image_url?: string | null
24
37
  featured_image_alt?: string | null
25
38
  author_name?: string | null
@@ -37,7 +50,7 @@ export type CmsEntry = {
37
50
  }
38
51
 
39
52
  export type CmsListOptions = {
40
- contentType?: string
53
+ contentType?: CmsContentType
41
54
  locale?: string
42
55
  category?: string
43
56
  tag?: string
@@ -46,11 +59,16 @@ export type CmsListOptions = {
46
59
  offset?: number
47
60
  }
48
61
 
62
+ export type CmsEntryOptions = {
63
+ contentType?: CmsContentType
64
+ locale?: string
65
+ }
66
+
49
67
  export function cmsConfig() {
50
68
  return medusaFetch<{
51
69
  enabled: true
52
70
  default_locale: string
53
- content_types: Array<{ key: string; label: string }>
71
+ content_types: Array<{ key: CmsContentType; label: string }>
54
72
  body_formats: string[]
55
73
  taxonomies: string[]
56
74
  }>("/store/cms/config", { next: { revalidate: 300 } })
@@ -72,7 +90,7 @@ export function listCmsEntries(options: CmsListOptions = {}) {
72
90
  )
73
91
  }
74
92
 
75
- export function getCmsEntry(slug: string, options: { contentType?: string; locale?: string } = {}) {
93
+ export function getCmsEntry(slug: string, options: CmsEntryOptions = {}) {
76
94
  const params = new URLSearchParams()
77
95
  if (options.contentType) params.set("content_type", options.contentType)
78
96
  if (options.locale) params.set("locale", options.locale)
@@ -83,6 +101,48 @@ export function getCmsEntry(slug: string, options: { contentType?: string; local
83
101
  )
84
102
  }
85
103
 
104
+ export function listBlogPosts(options: Omit<CmsListOptions, "contentType"> = {}) {
105
+ return listCmsEntries({
106
+ ...options,
107
+ contentType: CORE_CMS_CONTENT_TYPES.BLOG_POST,
108
+ })
109
+ }
110
+
111
+ export function getBlogPost(slug: string, options: Omit<CmsEntryOptions, "contentType"> = {}) {
112
+ return getCmsEntry(slug, {
113
+ ...options,
114
+ contentType: CORE_CMS_CONTENT_TYPES.BLOG_POST,
115
+ })
116
+ }
117
+
118
+ export function listCmsPages(options: Omit<CmsListOptions, "contentType"> = {}) {
119
+ return listCmsEntries({
120
+ ...options,
121
+ contentType: CORE_CMS_CONTENT_TYPES.PAGE,
122
+ })
123
+ }
124
+
125
+ export function getCmsPage(slug: string, options: Omit<CmsEntryOptions, "contentType"> = {}) {
126
+ return getCmsEntry(slug, {
127
+ ...options,
128
+ contentType: CORE_CMS_CONTENT_TYPES.PAGE,
129
+ })
130
+ }
131
+
132
+ export function listKnowledgeBaseEntries(options: Omit<CmsListOptions, "contentType"> = {}) {
133
+ return listCmsEntries({
134
+ ...options,
135
+ contentType: CORE_CMS_CONTENT_TYPES.KNOWLEDGE_BASE,
136
+ })
137
+ }
138
+
139
+ export function getKnowledgeBaseEntry(slug: string, options: Omit<CmsEntryOptions, "contentType"> = {}) {
140
+ return getCmsEntry(slug, {
141
+ ...options,
142
+ contentType: CORE_CMS_CONTENT_TYPES.KNOWLEDGE_BASE,
143
+ })
144
+ }
145
+
86
146
  export function listCmsTaxonomy(options: { taxonomy?: "category" | "tag"; locale?: string } = {}) {
87
147
  const params = new URLSearchParams()
88
148
  if (options.taxonomy) params.set("taxonomy", options.taxonomy)
@@ -94,7 +154,9 @@ export function listCmsTaxonomy(options: { taxonomy?: "category" | "tag"; locale
94
154
  )
95
155
  }
96
156
 
97
- export function cmsEntrySeo(entry: CmsEntry) {
157
+ export function cmsEntrySeo(entry: CmsEntry): Metadata {
158
+ const image = entry.og_image_url || entry.featured_image_url || undefined
159
+
98
160
  return {
99
161
  title: entry.seo_title || entry.title,
100
162
  description: entry.seo_description || entry.excerpt || undefined,
@@ -103,10 +165,8 @@ export function cmsEntrySeo(entry: CmsEntry) {
103
165
  openGraph: {
104
166
  title: entry.seo_title || entry.title,
105
167
  description: entry.seo_description || entry.excerpt || undefined,
106
- images: entry.og_image_url || entry.featured_image_url
107
- ? [entry.og_image_url || entry.featured_image_url]
108
- : undefined,
109
- type: entry.content_type === "blog_post" ? "article" : "website",
168
+ images: image ? [image] : undefined,
169
+ type: entry.content_type === CORE_CMS_CONTENT_TYPES.BLOG_POST ? "article" : "website",
110
170
  },
111
171
  }
112
172
  }
@@ -0,0 +1,57 @@
1
+ export function focusFirstInvalidField(root?: ParentNode) {
2
+ if (typeof document === "undefined") return null
3
+ const targetRoot = root || document
4
+ const invalid = targetRoot.querySelector<HTMLElement>(
5
+ "[aria-invalid='true'], input:invalid, select:invalid, textarea:invalid",
6
+ )
7
+ invalid?.focus()
8
+ invalid?.scrollIntoView({ behavior: prefersReducedMotion() ? "auto" : "smooth", block: "center" })
9
+ return invalid || null
10
+ }
11
+
12
+ export function fieldErrorId(fieldName: string) {
13
+ return `field-error-${fieldName.replace(/[^a-zA-Z0-9_-]+/g, "-")}`
14
+ }
15
+
16
+ export function humanizeStorefrontError(error: unknown, locale: "hu" | "en" = "hu") {
17
+ const fallback = locale === "en"
18
+ ? "Something went wrong. Please try again."
19
+ : "Hiba történt. Kérjük, próbáld újra."
20
+ if (!(error instanceof Error)) return fallback
21
+
22
+ const message = error.message.trim()
23
+ if (!message) return fallback
24
+ if (/network|fetch failed|failed to fetch|econn|timeout/i.test(message)) {
25
+ return locale === "en"
26
+ ? "The service is temporarily unavailable. Please try again shortly."
27
+ : "A szolgáltatás átmenetileg nem érhető el. Kérjük, próbáld újra rövidesen."
28
+ }
29
+ if (/unauthorized|401/i.test(message)) {
30
+ return locale === "en" ? "Please sign in to continue." : "A folytatáshoz jelentkezz be."
31
+ }
32
+ if (/forbidden|403/i.test(message)) {
33
+ return locale === "en" ? "You don't have permission for this action." : "Ehhez a művelethez nincs jogosultságod."
34
+ }
35
+ return message.length <= 240 ? message : fallback
36
+ }
37
+
38
+ export function prefersReducedMotion() {
39
+ if (typeof window === "undefined" || typeof window.matchMedia !== "function") return false
40
+ const override = document.documentElement.dataset.motion
41
+ if (override === "reduced") return true
42
+ if (override === "full") return false
43
+ return window.matchMedia("(prefers-reduced-motion: reduce)").matches
44
+ }
45
+
46
+ export function accessibilityProps(input: {
47
+ name: string
48
+ error?: string | null
49
+ required?: boolean
50
+ }) {
51
+ const errorId = fieldErrorId(input.name)
52
+ return {
53
+ "aria-invalid": input.error ? true : undefined,
54
+ "aria-describedby": input.error ? errorId : undefined,
55
+ "aria-required": input.required || undefined,
56
+ }
57
+ }
@@ -0,0 +1,53 @@
1
+ import { medusaFetch } from "./client"
2
+
3
+ export type NewsletterConfig = {
4
+ enabled: boolean
5
+ double_opt_in: boolean
6
+ consent_version: string
7
+ consent_url: string | null
8
+ }
9
+
10
+ export type NewsletterSubscriptionState = {
11
+ subscriber: {
12
+ id: string
13
+ status: "pending" | "subscribed" | "unsubscribed"
14
+ double_opt_in?: boolean
15
+ }
16
+ message: string
17
+ }
18
+
19
+ export function newsletterConfig() {
20
+ return medusaFetch<NewsletterConfig>("/store/newsletter/config", {
21
+ next: { revalidate: 300 },
22
+ })
23
+ }
24
+
25
+ export function subscribeNewsletter(input: {
26
+ email: string
27
+ consent: true
28
+ source?: string
29
+ page_url?: string
30
+ utm?: Partial<Record<"utm_source" | "utm_medium" | "utm_campaign" | "utm_term" | "utm_content", string>>
31
+ }) {
32
+ return medusaFetch<NewsletterSubscriptionState>("/store/newsletter", {
33
+ method: "POST",
34
+ body: JSON.stringify(input),
35
+ cache: "no-store",
36
+ })
37
+ }
38
+
39
+ export function confirmNewsletter(token: string) {
40
+ return medusaFetch<NewsletterSubscriptionState>("/store/newsletter/confirm", {
41
+ method: "POST",
42
+ body: JSON.stringify({ token }),
43
+ cache: "no-store",
44
+ })
45
+ }
46
+
47
+ export function unsubscribeNewsletter(token: string) {
48
+ return medusaFetch<NewsletterSubscriptionState>("/store/newsletter/unsubscribe", {
49
+ method: "POST",
50
+ body: JSON.stringify({ token }),
51
+ cache: "no-store",
52
+ })
53
+ }
@@ -0,0 +1,40 @@
1
+ import { medusaFetch } from "./client"
2
+
3
+ export type ProductReview = {
4
+ id: string
5
+ product_id: string
6
+ customer_name: string
7
+ rating: number
8
+ body: string
9
+ verified_purchase: boolean
10
+ status?: "pending" | "approved" | "rejected"
11
+ created_at?: string
12
+ updated_at?: string
13
+ }
14
+
15
+ export type ProductReviewSummary = {
16
+ average: number
17
+ count: number
18
+ }
19
+
20
+ export function listProductReviews(productId: string, options: { limit?: number; offset?: number } = {}) {
21
+ const params = new URLSearchParams()
22
+ if (options.limit != null) params.set("limit", String(options.limit))
23
+ if (options.offset != null) params.set("offset", String(options.offset))
24
+ const query = params.toString()
25
+ return medusaFetch<{
26
+ reviews: ProductReview[]
27
+ summary: ProductReviewSummary
28
+ limit: number
29
+ offset: number
30
+ }>(`/store/products/${encodeURIComponent(productId)}/reviews${query ? `?${query}` : ""}`, {
31
+ cache: "no-store",
32
+ })
33
+ }
34
+
35
+ export function submitProductReview(productId: string, input: { rating: number; body: string }) {
36
+ return medusaFetch<{ review: ProductReview }>(`/store/products/${encodeURIComponent(productId)}/reviews`, {
37
+ method: "POST",
38
+ body: JSON.stringify(input),
39
+ })
40
+ }
@@ -0,0 +1,57 @@
1
+ export type SharePayload = {
2
+ title?: string
3
+ text?: string
4
+ url: string
5
+ }
6
+
7
+ export type ShareResult = "shared" | "copied" | "cancelled"
8
+
9
+ export async function shareContent(payload: SharePayload): Promise<ShareResult> {
10
+ if (typeof window === "undefined") return "cancelled"
11
+
12
+ if (typeof navigator.share === "function") {
13
+ try {
14
+ await navigator.share({
15
+ title: payload.title,
16
+ text: payload.text,
17
+ url: payload.url,
18
+ })
19
+ return "shared"
20
+ } catch (error) {
21
+ if (error instanceof DOMException && error.name === "AbortError") return "cancelled"
22
+ }
23
+ }
24
+
25
+ await copyText(payload.url)
26
+ return "copied"
27
+ }
28
+
29
+ export async function copyText(value: string) {
30
+ if (typeof navigator !== "undefined" && navigator.clipboard?.writeText) {
31
+ await navigator.clipboard.writeText(value)
32
+ return
33
+ }
34
+
35
+ if (typeof document === "undefined") throw new Error("Clipboard is not available.")
36
+ const input = document.createElement("textarea")
37
+ input.value = value
38
+ input.setAttribute("readonly", "")
39
+ input.style.position = "fixed"
40
+ input.style.opacity = "0"
41
+ document.body.appendChild(input)
42
+ input.select()
43
+ const copied = document.execCommand("copy")
44
+ input.remove()
45
+ if (!copied) throw new Error("Could not copy to clipboard.")
46
+ }
47
+
48
+ export function shareFallbackLinks(payload: SharePayload) {
49
+ const url = encodeURIComponent(payload.url)
50
+ const title = encodeURIComponent(payload.title || "")
51
+ const text = encodeURIComponent(payload.text || payload.title || "")
52
+ return {
53
+ facebook: `https://www.facebook.com/sharer/sharer.php?u=${url}`,
54
+ linkedin: `https://www.linkedin.com/sharing/share-offsite/?url=${url}`,
55
+ email: `mailto:?subject=${title}&body=${text}%0A%0A${url}`,
56
+ }
57
+ }
@@ -0,0 +1,88 @@
1
+ import { medusaFetch } from "./client"
2
+
3
+ export type WishlistProduct = {
4
+ id: string
5
+ title?: string
6
+ handle?: string
7
+ thumbnail?: string | null
8
+ status?: string
9
+ }
10
+
11
+ export type WishlistItem = {
12
+ id: string
13
+ product_id: string
14
+ created_at?: string
15
+ product?: WishlistProduct | null
16
+ }
17
+
18
+ const GUEST_WISHLIST_KEY = "hszrdm_guest_wishlist_v1"
19
+
20
+ export function listWishlist() {
21
+ return medusaFetch<{ items: WishlistItem[]; count: number }>("/store/account/wishlist", {
22
+ cache: "no-store",
23
+ })
24
+ }
25
+
26
+ export function addWishlistProduct(productId: string) {
27
+ return medusaFetch<{ item: WishlistItem; already_saved: boolean }>("/store/account/wishlist", {
28
+ method: "POST",
29
+ body: JSON.stringify({ product_id: productId }),
30
+ })
31
+ }
32
+
33
+ export function removeWishlistProduct(productId: string) {
34
+ return medusaFetch<{ product_id: string; deleted: boolean }>(
35
+ `/store/account/wishlist/${encodeURIComponent(productId)}`,
36
+ { method: "DELETE" },
37
+ )
38
+ }
39
+
40
+ export function mergeWishlistProducts(productIds: string[]) {
41
+ return medusaFetch<{ merged: number; ignored: number; product_ids: string[] }>("/store/account/wishlist/merge", {
42
+ method: "POST",
43
+ body: JSON.stringify({ product_ids: productIds }),
44
+ })
45
+ }
46
+
47
+ export function getGuestWishlistProductIds() {
48
+ if (typeof window === "undefined") return []
49
+ try {
50
+ const parsed = JSON.parse(window.localStorage.getItem(GUEST_WISHLIST_KEY) || "[]")
51
+ if (!Array.isArray(parsed)) return []
52
+ return [...new Set(parsed.map((item) => typeof item === "string" ? item.trim() : "").filter(Boolean))]
53
+ } catch {
54
+ return []
55
+ }
56
+ }
57
+
58
+ export function addGuestWishlistProduct(productId: string) {
59
+ const ids = getGuestWishlistProductIds()
60
+ const normalized = productId.trim()
61
+ if (!normalized) return ids
62
+ const next = ids.includes(normalized) ? ids : [...ids, normalized]
63
+ writeGuestWishlist(next)
64
+ return next
65
+ }
66
+
67
+ export function removeGuestWishlistProduct(productId: string) {
68
+ const next = getGuestWishlistProductIds().filter((id) => id !== productId)
69
+ writeGuestWishlist(next)
70
+ return next
71
+ }
72
+
73
+ export function clearGuestWishlist() {
74
+ if (typeof window !== "undefined") window.localStorage.removeItem(GUEST_WISHLIST_KEY)
75
+ }
76
+
77
+ export async function mergeGuestWishlistAfterLogin() {
78
+ const ids = getGuestWishlistProductIds()
79
+ if (!ids.length) return { merged: 0, ignored: 0, product_ids: [] as string[] }
80
+ const result = await mergeWishlistProducts(ids)
81
+ clearGuestWishlist()
82
+ return result
83
+ }
84
+
85
+ function writeGuestWishlist(ids: string[]) {
86
+ if (typeof window === "undefined") return
87
+ window.localStorage.setItem(GUEST_WISHLIST_KEY, JSON.stringify([...new Set(ids)].slice(0, 200)))
88
+ }
@@ -8,9 +8,15 @@ export const STOREFRONT_ROUTES = {
8
8
  checkout: "/hu/penztar",
9
9
  checkoutSuccess: "/hu/penztar/sikeres-rendeles",
10
10
  account: "/hu/fiokom",
11
+ wishlist: "/hu/fiokom/kedvencek",
11
12
  orders: "/hu/fiokom/rendelesek",
12
13
  resetPassword: "/hu/jelszo-visszaallitas",
13
14
  legal: "/hu/jogi",
15
+ blog: "/hu/blog",
16
+ knowledgeBase: "/hu/tudastar",
17
+ cmsPages: "/hu/oldalak",
18
+ quoteRequest: "/hu/ajanlatkeres",
19
+ contact: "/hu/kapcsolat",
14
20
  },
15
21
  en: {
16
22
  medusaLocale: "en-US",
@@ -21,9 +27,15 @@ export const STOREFRONT_ROUTES = {
21
27
  checkout: "/en/checkout",
22
28
  checkoutSuccess: "/en/checkout/success",
23
29
  account: "/en/account",
30
+ wishlist: "/en/account/wishlist",
24
31
  orders: "/en/account/orders",
25
32
  resetPassword: "/en/reset-password",
26
33
  legal: "/en/legal",
34
+ blog: "/en/blog",
35
+ knowledgeBase: "/en/knowledge-base",
36
+ cmsPages: "/en/pages",
37
+ quoteRequest: "/en/quote-request",
38
+ contact: "/en/contact",
27
39
  },
28
40
  } as const
29
41
 
@@ -57,6 +69,18 @@ export function orderPath(locale: StorefrontLocale, orderId: string) {
57
69
  return `${STOREFRONT_ROUTES[locale].orders}/${encodeURIComponent(orderId)}`
58
70
  }
59
71
 
72
+ export function blogPostPath(locale: StorefrontLocale, slug: string) {
73
+ return `${STOREFRONT_ROUTES[locale].blog}/${encodeURIComponent(slug)}`
74
+ }
75
+
76
+ export function knowledgeBasePath(locale: StorefrontLocale, slug: string) {
77
+ return `${STOREFRONT_ROUTES[locale].knowledgeBase}/${encodeURIComponent(slug)}`
78
+ }
79
+
80
+ export function cmsPagePath(locale: StorefrontLocale, slug: string) {
81
+ return `${STOREFRONT_ROUTES[locale].cmsPages}/${encodeURIComponent(slug)}`
82
+ }
83
+
60
84
  export function equivalentLocalePath(
61
85
  pathname: string,
62
86
  targetLocale: StorefrontLocale,
@@ -80,12 +104,21 @@ export function equivalentLocalePath(
80
104
  if (pathname === source.checkout) return target.checkout
81
105
  if (pathname === source.checkoutSuccess) return target.checkoutSuccess
82
106
  if (pathname === source.account) return target.account
107
+ if (pathname === source.wishlist) return target.wishlist
83
108
  if (pathname === source.orders) return target.orders
84
109
  if (pathname.startsWith(`${source.orders}/`)) {
85
110
  return `${target.orders}/${pathname.slice(source.orders.length + 1)}`
86
111
  }
87
112
  if (pathname === source.resetPassword) return target.resetPassword
88
113
  if (pathname === source.legal) return target.legal
114
+ if (pathname === source.blog) return target.blog
115
+ if (pathname.startsWith(`${source.blog}/`)) return `${target.blog}/${pathname.slice(source.blog.length + 1)}`
116
+ if (pathname === source.knowledgeBase) return target.knowledgeBase
117
+ if (pathname.startsWith(`${source.knowledgeBase}/`)) return `${target.knowledgeBase}/${pathname.slice(source.knowledgeBase.length + 1)}`
118
+ if (pathname === source.cmsPages) return target.cmsPages
119
+ if (pathname.startsWith(`${source.cmsPages}/`)) return `${target.cmsPages}/${pathname.slice(source.cmsPages.length + 1)}`
120
+ if (pathname === source.quoteRequest) return target.quoteRequest
121
+ if (pathname === source.contact) return target.contact
89
122
 
90
123
  return target.home
91
124
  }
@@ -55,27 +55,28 @@ function legacyRedirect(pathname: string, locale: StorefrontLocale) {
55
55
  if (pathname === "/checkout") return STOREFRONT_ROUTES[locale].checkout
56
56
  if (pathname === "/checkout/success") return STOREFRONT_ROUTES[locale].checkoutSuccess
57
57
  if (pathname === "/account") return STOREFRONT_ROUTES[locale].account
58
- if (pathname.startsWith("/account/orders/")) {
59
- return `${STOREFRONT_ROUTES[locale].orders}/${pathname.slice("/account/orders/".length)}`
60
- }
58
+ if (pathname === "/account/wishlist") return STOREFRONT_ROUTES[locale].wishlist
59
+ if (pathname.startsWith("/account/orders/")) return `${STOREFRONT_ROUTES[locale].orders}/${pathname.slice("/account/orders/".length)}`
61
60
  if (pathname === "/reset-password") return STOREFRONT_ROUTES[locale].resetPassword
62
61
  if (pathname === "/legal") return STOREFRONT_ROUTES[locale].legal
62
+ if (pathname === "/blog") return STOREFRONT_ROUTES[locale].blog
63
+ if (pathname.startsWith("/blog/")) return `${STOREFRONT_ROUTES[locale].blog}/${pathname.slice("/blog/".length)}`
64
+ if (pathname === "/knowledge-base") return STOREFRONT_ROUTES[locale].knowledgeBase
65
+ if (pathname.startsWith("/knowledge-base/")) return `${STOREFRONT_ROUTES[locale].knowledgeBase}/${pathname.slice("/knowledge-base/".length)}`
66
+ if (pathname.startsWith("/pages/")) return `${STOREFRONT_ROUTES[locale].cmsPages}/${pathname.slice("/pages/".length)}`
67
+ if (pathname === "/quote-request") return STOREFRONT_ROUTES[locale].quoteRequest
68
+ if (pathname === "/contact") return STOREFRONT_ROUTES[locale].contact
63
69
 
64
70
  if (pathname === "/hu/products") return STOREFRONT_ROUTES.hu.products
65
- if (pathname.startsWith("/hu/products/")) {
66
- return `${STOREFRONT_ROUTES.hu.products}/${pathname.slice("/hu/products/".length)}`
67
- }
71
+ if (pathname.startsWith("/hu/products/")) return `${STOREFRONT_ROUTES.hu.products}/${pathname.slice("/hu/products/".length)}`
68
72
  if (pathname === "/hu/categories") return STOREFRONT_ROUTES.hu.categories
69
- if (pathname.startsWith("/hu/categories/")) {
70
- return `${STOREFRONT_ROUTES.hu.categories}/${pathname.slice("/hu/categories/".length)}`
71
- }
73
+ if (pathname.startsWith("/hu/categories/")) return `${STOREFRONT_ROUTES.hu.categories}/${pathname.slice("/hu/categories/".length)}`
72
74
  if (pathname === "/hu/cart") return STOREFRONT_ROUTES.hu.cart
73
75
  if (pathname === "/hu/checkout") return STOREFRONT_ROUTES.hu.checkout
74
76
  if (pathname === "/hu/checkout/success") return STOREFRONT_ROUTES.hu.checkoutSuccess
75
77
  if (pathname === "/hu/account") return STOREFRONT_ROUTES.hu.account
76
- if (pathname.startsWith("/hu/account/orders/")) {
77
- return `${STOREFRONT_ROUTES.hu.orders}/${pathname.slice("/hu/account/orders/".length)}`
78
- }
78
+ if (pathname === "/hu/account/wishlist") return STOREFRONT_ROUTES.hu.wishlist
79
+ if (pathname.startsWith("/hu/account/orders/")) return `${STOREFRONT_ROUTES.hu.orders}/${pathname.slice("/hu/account/orders/".length)}`
79
80
  if (pathname === "/hu/reset-password") return STOREFRONT_ROUTES.hu.resetPassword
80
81
  if (pathname === "/hu/legal") return STOREFRONT_ROUTES.hu.legal
81
82
 
@@ -89,24 +90,26 @@ function internalRewrite(pathname: string, locale: StorefrontLocale) {
89
90
 
90
91
  if (locale === "hu") {
91
92
  if (pathname === routes.products) return "/hu/products"
92
- if (pathname.startsWith(`${routes.products}/`)) {
93
- return `/hu/products/${pathname.slice(routes.products.length + 1)}`
94
- }
93
+ if (pathname.startsWith(`${routes.products}/`)) return `/hu/products/${pathname.slice(routes.products.length + 1)}`
95
94
  if (pathname === routes.categories) return "/hu/categories"
96
- if (pathname.startsWith(`${routes.categories}/`)) {
97
- return `/hu/categories/${pathname.slice(routes.categories.length + 1)}`
98
- }
95
+ if (pathname.startsWith(`${routes.categories}/`)) return `/hu/categories/${pathname.slice(routes.categories.length + 1)}`
99
96
  }
100
97
 
101
98
  if (pathname === routes.cart) return "/cart"
102
99
  if (pathname === routes.checkout) return "/checkout"
103
100
  if (pathname === routes.checkoutSuccess) return "/checkout/success"
104
101
  if (pathname === routes.account) return "/account"
105
- if (pathname.startsWith(`${routes.orders}/`)) {
106
- return `/account/orders/${pathname.slice(routes.orders.length + 1)}`
107
- }
102
+ if (pathname === routes.wishlist) return "/account/wishlist"
103
+ if (pathname.startsWith(`${routes.orders}/`)) return `/account/orders/${pathname.slice(routes.orders.length + 1)}`
108
104
  if (pathname === routes.resetPassword) return "/reset-password"
109
105
  if (pathname === routes.legal) return "/legal"
106
+ if (pathname === routes.blog) return "/blog"
107
+ if (pathname.startsWith(`${routes.blog}/`)) return `/blog/${pathname.slice(routes.blog.length + 1)}`
108
+ if (pathname === routes.knowledgeBase) return "/knowledge-base"
109
+ if (pathname.startsWith(`${routes.knowledgeBase}/`)) return `/knowledge-base/${pathname.slice(routes.knowledgeBase.length + 1)}`
110
+ if (pathname.startsWith(`${routes.cmsPages}/`)) return `/pages/${pathname.slice(routes.cmsPages.length + 1)}`
111
+ if (pathname === routes.quoteRequest) return "/quote-request"
112
+ if (pathname === routes.contact) return "/contact"
110
113
 
111
114
  return null
112
115
  }
@@ -132,11 +135,5 @@ function cookieOptions() {
132
135
  }
133
136
 
134
137
  function isInfrastructurePath(pathname: string) {
135
- return (
136
- pathname === "/robots.txt" ||
137
- pathname === "/sitemap.xml" ||
138
- pathname.startsWith("/sitemap.xml/") ||
139
- pathname.startsWith("/api/") ||
140
- pathname.startsWith("/static/")
141
- )
138
+ return pathname === "/robots.txt" || pathname === "/sitemap.xml" || pathname.startsWith("/sitemap.xml/") || pathname.startsWith("/api/") || pathname.startsWith("/static/")
142
139
  }