@hszrdm/create-commerce 1.2.0 → 1.4.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/README.md +92 -1
- package/package.json +2 -2
- package/templates/backend/.env.example +288 -76
- package/templates/backend/package.json +5 -3
- package/templates/backend/scripts/materialize-production.mjs +37 -0
- package/templates/backend/scripts/production-assets/backup.sh +56 -0
- package/templates/backend/scripts/production-assets/deploy.sh +67 -0
- package/templates/backend/scripts/production-assets/ecosystem.config.cjs.tpl +24 -0
- package/templates/backend/scripts/production-assets/install.sh +200 -0
- package/templates/backend/scripts/production-assets/restore.sh +68 -0
- package/templates/backend/scripts/verify-env-contract.mjs +58 -0
- 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
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import { FormEvent, useEffect, useState } from "react"
|
|
4
|
+
import {
|
|
5
|
+
listProductReviews,
|
|
6
|
+
submitProductReview,
|
|
7
|
+
type ProductReview,
|
|
8
|
+
type ProductReviewSummary,
|
|
9
|
+
} from "@/lib/core/reviews"
|
|
10
|
+
import { useToast } from "@/components/toast-provider"
|
|
11
|
+
|
|
12
|
+
type Props = {
|
|
13
|
+
productId: string
|
|
14
|
+
locale: "hu" | "en"
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const EMPTY_SUMMARY: ProductReviewSummary = { average: 0, count: 0 }
|
|
18
|
+
|
|
19
|
+
export function ProductReviews({ productId, locale }: Props) {
|
|
20
|
+
const english = locale === "en"
|
|
21
|
+
const { showToast } = useToast()
|
|
22
|
+
const [reviews, setReviews] = useState<ProductReview[]>([])
|
|
23
|
+
const [summary, setSummary] = useState<ProductReviewSummary>(EMPTY_SUMMARY)
|
|
24
|
+
const [loading, setLoading] = useState(true)
|
|
25
|
+
const [loadError, setLoadError] = useState("")
|
|
26
|
+
const [rating, setRating] = useState(5)
|
|
27
|
+
const [body, setBody] = useState("")
|
|
28
|
+
const [submitting, setSubmitting] = useState(false)
|
|
29
|
+
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
let active = true
|
|
32
|
+
setLoading(true)
|
|
33
|
+
setLoadError("")
|
|
34
|
+
void listProductReviews(productId, { limit: 20 })
|
|
35
|
+
.then((result) => {
|
|
36
|
+
if (!active) return
|
|
37
|
+
setReviews(result.reviews)
|
|
38
|
+
setSummary(result.summary)
|
|
39
|
+
})
|
|
40
|
+
.catch((cause) => {
|
|
41
|
+
if (!active) return
|
|
42
|
+
setLoadError(cause instanceof Error ? cause.message : (english ? "Reviews are unavailable." : "A vélemények nem érhetők el."))
|
|
43
|
+
})
|
|
44
|
+
.finally(() => {
|
|
45
|
+
if (active) setLoading(false)
|
|
46
|
+
})
|
|
47
|
+
return () => {
|
|
48
|
+
active = false
|
|
49
|
+
}
|
|
50
|
+
}, [english, productId])
|
|
51
|
+
|
|
52
|
+
async function onSubmit(event: FormEvent<HTMLFormElement>) {
|
|
53
|
+
event.preventDefault()
|
|
54
|
+
if (!body.trim() || submitting) return
|
|
55
|
+
setSubmitting(true)
|
|
56
|
+
try {
|
|
57
|
+
await submitProductReview(productId, { rating, body: body.trim() })
|
|
58
|
+
setBody("")
|
|
59
|
+
setRating(5)
|
|
60
|
+
showToast({
|
|
61
|
+
tone: "success",
|
|
62
|
+
message: english
|
|
63
|
+
? "Thanks! Your review was submitted for moderation."
|
|
64
|
+
: "Köszönjük! A véleményed moderálásra elküldtük.",
|
|
65
|
+
})
|
|
66
|
+
} catch (cause) {
|
|
67
|
+
showToast({
|
|
68
|
+
tone: "error",
|
|
69
|
+
message: cause instanceof Error
|
|
70
|
+
? cause.message
|
|
71
|
+
: (english ? "The review could not be submitted." : "A véleményt nem sikerült elküldeni."),
|
|
72
|
+
})
|
|
73
|
+
} finally {
|
|
74
|
+
setSubmitting(false)
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return (
|
|
79
|
+
<section className="stack product-reviews" aria-labelledby="product-reviews-title">
|
|
80
|
+
<div className="section-heading">
|
|
81
|
+
<div>
|
|
82
|
+
<p className="eyebrow">{english ? "Customer feedback" : "Vásárlói visszajelzések"}</p>
|
|
83
|
+
<h2 id="product-reviews-title">{english ? "Reviews" : "Vélemények"}</h2>
|
|
84
|
+
</div>
|
|
85
|
+
<div className="review-summary" aria-label={english ? "Review summary" : "Értékelések összesítése"}>
|
|
86
|
+
<strong>{summary.count ? summary.average.toFixed(1) : "–"} / 5</strong>
|
|
87
|
+
<span>{summary.count} {english ? "reviews" : "vélemény"}</span>
|
|
88
|
+
</div>
|
|
89
|
+
</div>
|
|
90
|
+
|
|
91
|
+
<form className="panel stack-sm review-form" onSubmit={onSubmit}>
|
|
92
|
+
<div>
|
|
93
|
+
<label className="field-label" htmlFor="review-rating">{english ? "Rating" : "Értékelés"}</label>
|
|
94
|
+
<select id="review-rating" value={rating} onChange={(event) => setRating(Number(event.target.value))}>
|
|
95
|
+
{[5, 4, 3, 2, 1].map((value) => (
|
|
96
|
+
<option value={value} key={value}>{value} / 5</option>
|
|
97
|
+
))}
|
|
98
|
+
</select>
|
|
99
|
+
</div>
|
|
100
|
+
<div>
|
|
101
|
+
<label className="field-label" htmlFor="review-body">{english ? "Your review" : "Véleményed"}</label>
|
|
102
|
+
<textarea
|
|
103
|
+
id="review-body"
|
|
104
|
+
rows={5}
|
|
105
|
+
maxLength={5000}
|
|
106
|
+
required
|
|
107
|
+
value={body}
|
|
108
|
+
onChange={(event) => setBody(event.target.value)}
|
|
109
|
+
placeholder={english ? "Share your experience with this product." : "Írd le a tapasztalatodat a termékről."}
|
|
110
|
+
/>
|
|
111
|
+
<span className="field-hint">
|
|
112
|
+
{english ? "You must be signed in to submit a review." : "Vélemény beküldéséhez be kell jelentkezned."}
|
|
113
|
+
</span>
|
|
114
|
+
</div>
|
|
115
|
+
<button className="button" type="submit" disabled={submitting || !body.trim()}>
|
|
116
|
+
{submitting
|
|
117
|
+
? (english ? "Submitting…" : "Küldés…")
|
|
118
|
+
: (english ? "Submit review" : "Vélemény elküldése")}
|
|
119
|
+
</button>
|
|
120
|
+
</form>
|
|
121
|
+
|
|
122
|
+
{loading ? <div className="empty-state">{english ? "Loading reviews…" : "Vélemények betöltése…"}</div> : null}
|
|
123
|
+
{!loading && loadError ? <div className="empty-state">{loadError}</div> : null}
|
|
124
|
+
{!loading && !loadError && !reviews.length ? (
|
|
125
|
+
<div className="empty-state">{english ? "No approved reviews yet." : "Még nincs jóváhagyott vélemény."}</div>
|
|
126
|
+
) : null}
|
|
127
|
+
{reviews.length ? (
|
|
128
|
+
<div className="review-list">
|
|
129
|
+
{reviews.map((review) => (
|
|
130
|
+
<article className="panel review-card" key={review.id}>
|
|
131
|
+
<div className="review-card-heading">
|
|
132
|
+
<div>
|
|
133
|
+
<strong>{review.customer_name}</strong>
|
|
134
|
+
{review.verified_purchase ? <span className="verified-badge">{english ? "Verified purchase" : "Ellenőrzött vásárlás"}</span> : null}
|
|
135
|
+
</div>
|
|
136
|
+
<span aria-label={`${review.rating} / 5`}>{"★".repeat(review.rating)}{"☆".repeat(Math.max(0, 5 - review.rating))}</span>
|
|
137
|
+
</div>
|
|
138
|
+
<p>{review.body}</p>
|
|
139
|
+
{review.created_at ? (
|
|
140
|
+
<time className="muted small" dateTime={review.created_at}>
|
|
141
|
+
{new Intl.DateTimeFormat(english ? "en-US" : "hu-HU", { dateStyle: "medium" }).format(new Date(review.created_at))}
|
|
142
|
+
</time>
|
|
143
|
+
) : null}
|
|
144
|
+
</article>
|
|
145
|
+
))}
|
|
146
|
+
</div>
|
|
147
|
+
) : null}
|
|
148
|
+
</section>
|
|
149
|
+
)
|
|
150
|
+
}
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import { FormEvent, useState } from "react"
|
|
4
|
+
import { submitQuoteRequest } from "@/lib/core/quotes"
|
|
5
|
+
import { useToast } from "@/components/toast-provider"
|
|
6
|
+
|
|
7
|
+
type ExtraField = {
|
|
8
|
+
key: string
|
|
9
|
+
label: string
|
|
10
|
+
type: "text" | "textarea" | "number" | "boolean" | "select"
|
|
11
|
+
required: boolean
|
|
12
|
+
options?: string[]
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
type Props = {
|
|
16
|
+
locale: "hu" | "en"
|
|
17
|
+
config: {
|
|
18
|
+
enabled: boolean
|
|
19
|
+
order_types: string[]
|
|
20
|
+
extra_fields: Array<Record<string, unknown>>
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function QuoteRequestForm({ locale, config }: Props) {
|
|
25
|
+
const english = locale === "en"
|
|
26
|
+
const { showToast } = useToast()
|
|
27
|
+
const [submitting, setSubmitting] = useState(false)
|
|
28
|
+
const extraFields = config.extra_fields.map(normalizeExtraField).filter((field): field is ExtraField => Boolean(field))
|
|
29
|
+
|
|
30
|
+
if (!config.enabled) {
|
|
31
|
+
return <div className="empty-state">{english ? "Quote requests are currently unavailable." : "Az ajánlatkérés jelenleg nem elérhető."}</div>
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
async function onSubmit(event: FormEvent<HTMLFormElement>) {
|
|
35
|
+
event.preventDefault()
|
|
36
|
+
if (submitting) return
|
|
37
|
+
const form = event.currentTarget
|
|
38
|
+
const data = new FormData(form)
|
|
39
|
+
const orderType = String(data.get("order_type") || "one_time") === "recurring" ? "recurring" : "one_time"
|
|
40
|
+
const itemTitle = String(data.get("item_title") || "").trim()
|
|
41
|
+
const itemQuantity = Number(data.get("item_quantity") || 1)
|
|
42
|
+
const extra_fields: Record<string, unknown> = {}
|
|
43
|
+
|
|
44
|
+
for (const field of extraFields) {
|
|
45
|
+
const raw = data.get(`extra_${field.key}`)
|
|
46
|
+
if (field.type === "boolean") extra_fields[field.key] = raw === "on"
|
|
47
|
+
else if (field.type === "number" && raw !== null && String(raw).trim()) extra_fields[field.key] = Number(raw)
|
|
48
|
+
else if (raw !== null && String(raw).trim()) extra_fields[field.key] = String(raw).trim()
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
setSubmitting(true)
|
|
52
|
+
try {
|
|
53
|
+
await submitQuoteRequest({
|
|
54
|
+
company_name: text(data.get("company_name")),
|
|
55
|
+
tax_number: text(data.get("tax_number")),
|
|
56
|
+
company_address: text(data.get("company_address")),
|
|
57
|
+
contact_name: String(data.get("contact_name") || "").trim(),
|
|
58
|
+
contact_email: String(data.get("contact_email") || "").trim(),
|
|
59
|
+
contact_phone: text(data.get("contact_phone")),
|
|
60
|
+
order_type: orderType,
|
|
61
|
+
recurrence: orderType === "recurring" ? text(data.get("recurrence")) : undefined,
|
|
62
|
+
note: text(data.get("note")),
|
|
63
|
+
extra_fields,
|
|
64
|
+
items: [{
|
|
65
|
+
title: itemTitle,
|
|
66
|
+
quantity: Number.isInteger(itemQuantity) && itemQuantity > 0 ? itemQuantity : 1,
|
|
67
|
+
unit_label: text(data.get("item_unit")),
|
|
68
|
+
custom_request: text(data.get("item_request")),
|
|
69
|
+
is_custom: true,
|
|
70
|
+
}],
|
|
71
|
+
})
|
|
72
|
+
form.reset()
|
|
73
|
+
showToast({
|
|
74
|
+
tone: "success",
|
|
75
|
+
message: english ? "Your quote request has been sent." : "Az ajánlatkérésedet elküldtük.",
|
|
76
|
+
})
|
|
77
|
+
} catch (cause) {
|
|
78
|
+
showToast({
|
|
79
|
+
tone: "error",
|
|
80
|
+
message: cause instanceof Error
|
|
81
|
+
? cause.message
|
|
82
|
+
: (english ? "The quote request could not be sent." : "Az ajánlatkérést nem sikerült elküldeni."),
|
|
83
|
+
})
|
|
84
|
+
} finally {
|
|
85
|
+
setSubmitting(false)
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return (
|
|
90
|
+
<form className="panel stack quote-request-form" onSubmit={onSubmit}>
|
|
91
|
+
<div className="form-grid">
|
|
92
|
+
<Field name="contact_name" label={english ? "Contact name" : "Kapcsolattartó neve"} required />
|
|
93
|
+
<Field name="contact_email" label={english ? "Email address" : "E-mail-cím"} type="email" required />
|
|
94
|
+
<Field name="contact_phone" label={english ? "Phone" : "Telefonszám"} type="tel" />
|
|
95
|
+
<Field name="company_name" label={english ? "Company" : "Cégnév"} />
|
|
96
|
+
<Field name="tax_number" label={english ? "Tax number" : "Adószám"} />
|
|
97
|
+
<Field name="company_address" label={english ? "Company address" : "Cég címe"} />
|
|
98
|
+
</div>
|
|
99
|
+
|
|
100
|
+
<div className="form-grid">
|
|
101
|
+
<div>
|
|
102
|
+
<label className="field-label" htmlFor="quote-order-type">{english ? "Order type" : "Rendelés típusa"}</label>
|
|
103
|
+
<select id="quote-order-type" name="order_type" defaultValue="one_time">
|
|
104
|
+
<option value="one_time">{english ? "One-time" : "Egyszeri"}</option>
|
|
105
|
+
<option value="recurring">{english ? "Recurring" : "Rendszeres"}</option>
|
|
106
|
+
</select>
|
|
107
|
+
</div>
|
|
108
|
+
<Field name="recurrence" label={english ? "Recurrence, if applicable" : "Gyakoriság, ha rendszeres"} placeholder={english ? "e.g. monthly" : "pl. havonta"} />
|
|
109
|
+
</div>
|
|
110
|
+
|
|
111
|
+
<fieldset className="form-fieldset stack-sm">
|
|
112
|
+
<legend>{english ? "Requested item" : "Ajánlatkérési tétel"}</legend>
|
|
113
|
+
<div className="form-grid">
|
|
114
|
+
<Field name="item_title" label={english ? "Item / service" : "Termék / szolgáltatás"} required />
|
|
115
|
+
<Field name="item_quantity" label={english ? "Quantity" : "Mennyiség"} type="number" min="1" defaultValue="1" required />
|
|
116
|
+
<Field name="item_unit" label={english ? "Unit" : "Egység"} placeholder={english ? "pcs, m, kg…" : "db, m, kg…"} />
|
|
117
|
+
</div>
|
|
118
|
+
<div>
|
|
119
|
+
<label className="field-label" htmlFor="quote-item-request">{english ? "Custom request" : "Egyedi igény"}</label>
|
|
120
|
+
<textarea id="quote-item-request" name="item_request" rows={4} />
|
|
121
|
+
</div>
|
|
122
|
+
</fieldset>
|
|
123
|
+
|
|
124
|
+
{extraFields.length ? (
|
|
125
|
+
<fieldset className="form-fieldset stack-sm">
|
|
126
|
+
<legend>{english ? "Additional details" : "További adatok"}</legend>
|
|
127
|
+
<div className="form-grid">
|
|
128
|
+
{extraFields.map((field) => <ExtraFieldControl field={field} key={field.key} />)}
|
|
129
|
+
</div>
|
|
130
|
+
</fieldset>
|
|
131
|
+
) : null}
|
|
132
|
+
|
|
133
|
+
<div>
|
|
134
|
+
<label className="field-label" htmlFor="quote-note">{english ? "Message" : "Megjegyzés"}</label>
|
|
135
|
+
<textarea id="quote-note" name="note" rows={5} />
|
|
136
|
+
</div>
|
|
137
|
+
|
|
138
|
+
<button className="button button-large" type="submit" disabled={submitting}>
|
|
139
|
+
{submitting ? (english ? "Sending…" : "Küldés…") : (english ? "Request a quote" : "Ajánlatot kérek")}
|
|
140
|
+
</button>
|
|
141
|
+
</form>
|
|
142
|
+
)
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
function Field(props: {
|
|
146
|
+
name: string
|
|
147
|
+
label: string
|
|
148
|
+
type?: string
|
|
149
|
+
required?: boolean
|
|
150
|
+
placeholder?: string
|
|
151
|
+
min?: string
|
|
152
|
+
defaultValue?: string
|
|
153
|
+
}) {
|
|
154
|
+
const id = `quote-${props.name}`
|
|
155
|
+
return (
|
|
156
|
+
<div>
|
|
157
|
+
<label className="field-label" htmlFor={id}>{props.label}{props.required ? <span className="required-mark">*</span> : null}</label>
|
|
158
|
+
<input id={id} name={props.name} type={props.type || "text"} required={props.required} placeholder={props.placeholder} min={props.min} defaultValue={props.defaultValue} />
|
|
159
|
+
</div>
|
|
160
|
+
)
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
function ExtraFieldControl({ field }: { field: ExtraField }) {
|
|
164
|
+
const id = `quote-extra-${field.key}`
|
|
165
|
+
if (field.type === "boolean") {
|
|
166
|
+
return (
|
|
167
|
+
<label className="checkbox-row" htmlFor={id}>
|
|
168
|
+
<input id={id} name={`extra_${field.key}`} type="checkbox" required={field.required} />
|
|
169
|
+
<span>{field.label}</span>
|
|
170
|
+
</label>
|
|
171
|
+
)
|
|
172
|
+
}
|
|
173
|
+
if (field.type === "textarea") {
|
|
174
|
+
return (
|
|
175
|
+
<div>
|
|
176
|
+
<label className="field-label" htmlFor={id}>{field.label}{field.required ? <span className="required-mark">*</span> : null}</label>
|
|
177
|
+
<textarea id={id} name={`extra_${field.key}`} rows={4} required={field.required} />
|
|
178
|
+
</div>
|
|
179
|
+
)
|
|
180
|
+
}
|
|
181
|
+
if (field.type === "select") {
|
|
182
|
+
return (
|
|
183
|
+
<div>
|
|
184
|
+
<label className="field-label" htmlFor={id}>{field.label}{field.required ? <span className="required-mark">*</span> : null}</label>
|
|
185
|
+
<select id={id} name={`extra_${field.key}`} required={field.required} defaultValue="">
|
|
186
|
+
<option value="" disabled={field.required}>—</option>
|
|
187
|
+
{(field.options || []).map((option) => <option value={option} key={option}>{option}</option>)}
|
|
188
|
+
</select>
|
|
189
|
+
</div>
|
|
190
|
+
)
|
|
191
|
+
}
|
|
192
|
+
return <Field name={`extra_${field.key}`} label={field.label} type={field.type === "number" ? "number" : "text"} required={field.required} />
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
function normalizeExtraField(value: Record<string, unknown>): ExtraField | null {
|
|
196
|
+
const key = typeof value.key === "string" ? value.key : ""
|
|
197
|
+
const label = typeof value.label === "string" ? value.label : key
|
|
198
|
+
const type = typeof value.type === "string" ? value.type : "text"
|
|
199
|
+
if (!key || !["text", "textarea", "number", "boolean", "select"].includes(type)) return null
|
|
200
|
+
return {
|
|
201
|
+
key,
|
|
202
|
+
label,
|
|
203
|
+
type: type as ExtraField["type"],
|
|
204
|
+
required: value.required === true,
|
|
205
|
+
options: Array.isArray(value.options) ? value.options.filter((item): item is string => typeof item === "string") : undefined,
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
function text(value: FormDataEntryValue | null) {
|
|
210
|
+
const result = typeof value === "string" ? value.trim() : ""
|
|
211
|
+
return result || undefined
|
|
212
|
+
}
|
|
@@ -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
|
}
|