@hszrdm/create-commerce 1.2.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.
- package/package.json +2 -2
- package/templates/backend/.env.example +45 -0
- package/templates/backend/package.json +1 -1
- package/templates/storefront/README.md +14 -1
- package/templates/storefront/src/app/[countryCode]/products/[handle]/page.tsx +2 -0
- package/templates/storefront/src/app/blog/[slug]/page.tsx +36 -0
- package/templates/storefront/src/app/blog/page.tsx +25 -0
- package/templates/storefront/src/app/contact/page.tsx +25 -0
- package/templates/storefront/src/app/customer-capabilities.css +60 -0
- package/templates/storefront/src/app/knowledge-base/[slug]/page.tsx +35 -0
- package/templates/storefront/src/app/knowledge-base/page.tsx +25 -0
- package/templates/storefront/src/app/layout.tsx +11 -2
- package/templates/storefront/src/app/pages/[slug]/page.tsx +35 -0
- package/templates/storefront/src/app/quote-request/page.tsx +20 -0
- package/templates/storefront/src/components/cms-content.tsx +75 -0
- package/templates/storefront/src/components/lead-form.tsx +203 -0
- package/templates/storefront/src/components/newsletter-signup.tsx +107 -0
- package/templates/storefront/src/components/product-reviews.tsx +150 -0
- package/templates/storefront/src/components/quote-request-form.tsx +212 -0
- package/templates/storefront/src/lib/core/cms.ts +5 -4
- package/templates/storefront/src/lib/storefront-routes.ts +30 -0
- package/templates/storefront/src/proxy.ts +22 -28
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Metadata } from "next"
|
|
1
2
|
import { medusaFetch } from "./client"
|
|
2
3
|
import {
|
|
3
4
|
CORE_CMS_CONTENT_TYPES,
|
|
@@ -153,7 +154,9 @@ export function listCmsTaxonomy(options: { taxonomy?: "category" | "tag"; locale
|
|
|
153
154
|
)
|
|
154
155
|
}
|
|
155
156
|
|
|
156
|
-
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
|
+
|
|
157
160
|
return {
|
|
158
161
|
title: entry.seo_title || entry.title,
|
|
159
162
|
description: entry.seo_description || entry.excerpt || undefined,
|
|
@@ -162,9 +165,7 @@ export function cmsEntrySeo(entry: CmsEntry) {
|
|
|
162
165
|
openGraph: {
|
|
163
166
|
title: entry.seo_title || entry.title,
|
|
164
167
|
description: entry.seo_description || entry.excerpt || undefined,
|
|
165
|
-
images:
|
|
166
|
-
? [entry.og_image_url || entry.featured_image_url]
|
|
167
|
-
: undefined,
|
|
168
|
+
images: image ? [image] : undefined,
|
|
168
169
|
type: entry.content_type === CORE_CMS_CONTENT_TYPES.BLOG_POST ? "article" : "website",
|
|
169
170
|
},
|
|
170
171
|
}
|
|
@@ -12,6 +12,11 @@ export const STOREFRONT_ROUTES = {
|
|
|
12
12
|
orders: "/hu/fiokom/rendelesek",
|
|
13
13
|
resetPassword: "/hu/jelszo-visszaallitas",
|
|
14
14
|
legal: "/hu/jogi",
|
|
15
|
+
blog: "/hu/blog",
|
|
16
|
+
knowledgeBase: "/hu/tudastar",
|
|
17
|
+
cmsPages: "/hu/oldalak",
|
|
18
|
+
quoteRequest: "/hu/ajanlatkeres",
|
|
19
|
+
contact: "/hu/kapcsolat",
|
|
15
20
|
},
|
|
16
21
|
en: {
|
|
17
22
|
medusaLocale: "en-US",
|
|
@@ -26,6 +31,11 @@ export const STOREFRONT_ROUTES = {
|
|
|
26
31
|
orders: "/en/account/orders",
|
|
27
32
|
resetPassword: "/en/reset-password",
|
|
28
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",
|
|
29
39
|
},
|
|
30
40
|
} as const
|
|
31
41
|
|
|
@@ -59,6 +69,18 @@ export function orderPath(locale: StorefrontLocale, orderId: string) {
|
|
|
59
69
|
return `${STOREFRONT_ROUTES[locale].orders}/${encodeURIComponent(orderId)}`
|
|
60
70
|
}
|
|
61
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
|
+
|
|
62
84
|
export function equivalentLocalePath(
|
|
63
85
|
pathname: string,
|
|
64
86
|
targetLocale: StorefrontLocale,
|
|
@@ -89,6 +111,14 @@ export function equivalentLocalePath(
|
|
|
89
111
|
}
|
|
90
112
|
if (pathname === source.resetPassword) return target.resetPassword
|
|
91
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
|
|
92
122
|
|
|
93
123
|
return target.home
|
|
94
124
|
}
|
|
@@ -56,28 +56,27 @@ function legacyRedirect(pathname: string, locale: StorefrontLocale) {
|
|
|
56
56
|
if (pathname === "/checkout/success") return STOREFRONT_ROUTES[locale].checkoutSuccess
|
|
57
57
|
if (pathname === "/account") return STOREFRONT_ROUTES[locale].account
|
|
58
58
|
if (pathname === "/account/wishlist") return STOREFRONT_ROUTES[locale].wishlist
|
|
59
|
-
if (pathname.startsWith("/account/orders/")) {
|
|
60
|
-
return `${STOREFRONT_ROUTES[locale].orders}/${pathname.slice("/account/orders/".length)}`
|
|
61
|
-
}
|
|
59
|
+
if (pathname.startsWith("/account/orders/")) return `${STOREFRONT_ROUTES[locale].orders}/${pathname.slice("/account/orders/".length)}`
|
|
62
60
|
if (pathname === "/reset-password") return STOREFRONT_ROUTES[locale].resetPassword
|
|
63
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
|
|
64
69
|
|
|
65
70
|
if (pathname === "/hu/products") return STOREFRONT_ROUTES.hu.products
|
|
66
|
-
if (pathname.startsWith("/hu/products/")) {
|
|
67
|
-
return `${STOREFRONT_ROUTES.hu.products}/${pathname.slice("/hu/products/".length)}`
|
|
68
|
-
}
|
|
71
|
+
if (pathname.startsWith("/hu/products/")) return `${STOREFRONT_ROUTES.hu.products}/${pathname.slice("/hu/products/".length)}`
|
|
69
72
|
if (pathname === "/hu/categories") return STOREFRONT_ROUTES.hu.categories
|
|
70
|
-
if (pathname.startsWith("/hu/categories/")) {
|
|
71
|
-
return `${STOREFRONT_ROUTES.hu.categories}/${pathname.slice("/hu/categories/".length)}`
|
|
72
|
-
}
|
|
73
|
+
if (pathname.startsWith("/hu/categories/")) return `${STOREFRONT_ROUTES.hu.categories}/${pathname.slice("/hu/categories/".length)}`
|
|
73
74
|
if (pathname === "/hu/cart") return STOREFRONT_ROUTES.hu.cart
|
|
74
75
|
if (pathname === "/hu/checkout") return STOREFRONT_ROUTES.hu.checkout
|
|
75
76
|
if (pathname === "/hu/checkout/success") return STOREFRONT_ROUTES.hu.checkoutSuccess
|
|
76
77
|
if (pathname === "/hu/account") return STOREFRONT_ROUTES.hu.account
|
|
77
78
|
if (pathname === "/hu/account/wishlist") return STOREFRONT_ROUTES.hu.wishlist
|
|
78
|
-
if (pathname.startsWith("/hu/account/orders/")) {
|
|
79
|
-
return `${STOREFRONT_ROUTES.hu.orders}/${pathname.slice("/hu/account/orders/".length)}`
|
|
80
|
-
}
|
|
79
|
+
if (pathname.startsWith("/hu/account/orders/")) return `${STOREFRONT_ROUTES.hu.orders}/${pathname.slice("/hu/account/orders/".length)}`
|
|
81
80
|
if (pathname === "/hu/reset-password") return STOREFRONT_ROUTES.hu.resetPassword
|
|
82
81
|
if (pathname === "/hu/legal") return STOREFRONT_ROUTES.hu.legal
|
|
83
82
|
|
|
@@ -91,13 +90,9 @@ function internalRewrite(pathname: string, locale: StorefrontLocale) {
|
|
|
91
90
|
|
|
92
91
|
if (locale === "hu") {
|
|
93
92
|
if (pathname === routes.products) return "/hu/products"
|
|
94
|
-
if (pathname.startsWith(`${routes.products}/`)) {
|
|
95
|
-
return `/hu/products/${pathname.slice(routes.products.length + 1)}`
|
|
96
|
-
}
|
|
93
|
+
if (pathname.startsWith(`${routes.products}/`)) return `/hu/products/${pathname.slice(routes.products.length + 1)}`
|
|
97
94
|
if (pathname === routes.categories) return "/hu/categories"
|
|
98
|
-
if (pathname.startsWith(`${routes.categories}/`)) {
|
|
99
|
-
return `/hu/categories/${pathname.slice(routes.categories.length + 1)}`
|
|
100
|
-
}
|
|
95
|
+
if (pathname.startsWith(`${routes.categories}/`)) return `/hu/categories/${pathname.slice(routes.categories.length + 1)}`
|
|
101
96
|
}
|
|
102
97
|
|
|
103
98
|
if (pathname === routes.cart) return "/cart"
|
|
@@ -105,11 +100,16 @@ function internalRewrite(pathname: string, locale: StorefrontLocale) {
|
|
|
105
100
|
if (pathname === routes.checkoutSuccess) return "/checkout/success"
|
|
106
101
|
if (pathname === routes.account) return "/account"
|
|
107
102
|
if (pathname === routes.wishlist) return "/account/wishlist"
|
|
108
|
-
if (pathname.startsWith(`${routes.orders}/`)) {
|
|
109
|
-
return `/account/orders/${pathname.slice(routes.orders.length + 1)}`
|
|
110
|
-
}
|
|
103
|
+
if (pathname.startsWith(`${routes.orders}/`)) return `/account/orders/${pathname.slice(routes.orders.length + 1)}`
|
|
111
104
|
if (pathname === routes.resetPassword) return "/reset-password"
|
|
112
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"
|
|
113
113
|
|
|
114
114
|
return null
|
|
115
115
|
}
|
|
@@ -135,11 +135,5 @@ function cookieOptions() {
|
|
|
135
135
|
}
|
|
136
136
|
|
|
137
137
|
function isInfrastructurePath(pathname: string) {
|
|
138
|
-
return (
|
|
139
|
-
pathname === "/robots.txt" ||
|
|
140
|
-
pathname === "/sitemap.xml" ||
|
|
141
|
-
pathname.startsWith("/sitemap.xml/") ||
|
|
142
|
-
pathname.startsWith("/api/") ||
|
|
143
|
-
pathname.startsWith("/static/")
|
|
144
|
-
)
|
|
138
|
+
return pathname === "/robots.txt" || pathname === "/sitemap.xml" || pathname.startsWith("/sitemap.xml/") || pathname.startsWith("/api/") || pathname.startsWith("/static/")
|
|
145
139
|
}
|