@hszrdm/create-commerce 1.11.2 → 1.13.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 +1 -1
- package/templates/backend/.env.example +2 -0
- package/templates/backend/package.json +1 -1
- package/templates/storefront/package.json +2 -1
- package/templates/storefront/src/app/[countryCode]/categories/[handle]/page.tsx +2 -2
- package/templates/storefront/src/app/[countryCode]/products/[handle]/page.tsx +2 -2
- package/templates/storefront/src/app/[countryCode]/products/page.tsx +15 -0
- package/templates/storefront/src/app/account/layout.tsx +10 -0
- package/templates/storefront/src/app/blog/[slug]/page.tsx +23 -2
- package/templates/storefront/src/app/blog/page.tsx +13 -0
- package/templates/storefront/src/app/cart/layout.tsx +10 -0
- package/templates/storefront/src/app/cart-recovery/layout.tsx +10 -0
- package/templates/storefront/src/app/checkout/layout.tsx +10 -0
- package/templates/storefront/src/app/contact/page.tsx +13 -0
- package/templates/storefront/src/app/documents/page.tsx +10 -2
- package/templates/storefront/src/app/ertekeles/layout.tsx +10 -0
- package/templates/storefront/src/app/fiok-aktivalas/layout.tsx +10 -0
- package/templates/storefront/src/app/knowledge-base/[slug]/page.tsx +23 -2
- package/templates/storefront/src/app/knowledge-base/page.tsx +13 -0
- package/templates/storefront/src/app/layout.tsx +6 -0
- package/templates/storefront/src/app/legal/page.tsx +13 -0
- package/templates/storefront/src/app/newsletter/layout.tsx +10 -0
- package/templates/storefront/src/app/page.tsx +11 -0
- package/templates/storefront/src/app/pages/[slug]/page.tsx +23 -2
- package/templates/storefront/src/app/pages/page.tsx +13 -0
- package/templates/storefront/src/app/quote-request/page.tsx +13 -0
- package/templates/storefront/src/app/reset-password/layout.tsx +10 -0
- package/templates/storefront/src/app/robots.txt/route.ts +4 -1
- package/templates/storefront/src/app/sitemap.xml/route.ts +19 -3
- package/templates/storefront/src/components/checkout-flow.tsx +6 -2
- package/templates/storefront/src/lib/core/cms.ts +5 -3
- package/templates/storefront/src/lib/core/seo-output.ts +20 -0
- package/templates/storefront/src/lib/core/seo.ts +95 -9
- package/templates/storefront/src/lib/core/types.ts +1 -0
- package/templates/storefront/src/proxy.ts +56 -2
- package/templates/storefront/tests/carrier-pickup-adapter.test.mjs +16 -0
- package/templates/storefront/tests/technical-seo.test.mjs +42 -0
package/package.json
CHANGED
|
@@ -97,6 +97,8 @@ SMTP_USER=
|
|
|
97
97
|
SMTP_PASSWORD=
|
|
98
98
|
SMTP_FROM="Example Store <system@example.com>"
|
|
99
99
|
SMTP_REPLY_TO=
|
|
100
|
+
# Opcionális, a SMTP-szolgáltatónál engedélyezett alternatív feladócímek (Send As)
|
|
101
|
+
SMTP_ALLOWED_FROM_ADDRESSES=
|
|
100
102
|
|
|
101
103
|
EMAIL_CUSTOMER_WELCOME_ENABLED=
|
|
102
104
|
EMAIL_REGISTRATION_VERIFICATION_ENABLED=
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
"test:addresses": "node --experimental-strip-types --test tests/checkout-addresses.test.mjs",
|
|
14
14
|
"test:stripe": "node --experimental-strip-types --test tests/stripe-checkout-phase.test.mjs",
|
|
15
15
|
"test:company-tax": "node --experimental-strip-types --test tests/company-tax.test.mjs",
|
|
16
|
-
"test:ga4": "node --experimental-strip-types --test tests/ga4-bootstrap.test.mjs"
|
|
16
|
+
"test:ga4": "node --experimental-strip-types --test tests/ga4-bootstrap.test.mjs",
|
|
17
|
+
"test:seo": "node --experimental-strip-types --test tests/technical-seo.test.mjs"
|
|
17
18
|
},
|
|
18
19
|
"dependencies": {
|
|
19
20
|
"@stripe/react-stripe-js": "7.0.0",
|
|
@@ -5,7 +5,7 @@ import { getCoreConfig } from "@/lib/core/client"
|
|
|
5
5
|
import { checkoutApi } from "@/lib/core/checkout"
|
|
6
6
|
import { getCategoryByHandle, listProducts } from "@/lib/core/catalog"
|
|
7
7
|
import { stringValue } from "@/lib/core/commerce"
|
|
8
|
-
import { metadataFromCore, structuredDataForEntity } from "@/lib/core/seo"
|
|
8
|
+
import { metadataFromCore, serializeJsonLd, structuredDataForEntity } from "@/lib/core/seo"
|
|
9
9
|
import { storefrontCopy } from "@/lib/storefront-copy"
|
|
10
10
|
import { medusaLocale, storefrontLocale } from "@/lib/storefront-routes"
|
|
11
11
|
|
|
@@ -39,7 +39,7 @@ export default async function CategoryPage({ params }: { params: Promise<{ count
|
|
|
39
39
|
|
|
40
40
|
return (
|
|
41
41
|
<div className="stack page-section">
|
|
42
|
-
{jsonLd ? <script className="jsonld" type="application/ld+json" dangerouslySetInnerHTML={{ __html:
|
|
42
|
+
{jsonLd ? <script className="jsonld" type="application/ld+json" dangerouslySetInnerHTML={{ __html: serializeJsonLd(jsonLd) }} /> : null}
|
|
43
43
|
<div className="page-heading"><div><p className="eyebrow">{copy.category}</p><h1>{stringValue(category.name)}</h1>{category.description ? <p className="muted">{stringValue(category.description)}</p> : null}</div></div>
|
|
44
44
|
{products.length ? <div className="product-grid">{products.map((product) => <ProductCard config={config} product={product} locale={locale} key={stringValue(product.id)} />)}</div> : <div className="empty-state">{copy.emptyCategory}</div>}
|
|
45
45
|
{categoryId ? <CategoryDocuments categoryId={categoryId} locale={apiLocale} /> : null}
|
|
@@ -13,7 +13,7 @@ import { checkoutApi } from "@/lib/core/checkout"
|
|
|
13
13
|
import { getProductByHandle } from "@/lib/core/catalog"
|
|
14
14
|
import { asRecords, productVariantCurrency, productVariantPriceBreakdown, stringValue } from "@/lib/core/commerce"
|
|
15
15
|
import { googleAdsRemarketingItemFromProduct } from "@/lib/core/google-ads"
|
|
16
|
-
import { metadataFromCore, structuredDataForEntity } from "@/lib/core/seo"
|
|
16
|
+
import { metadataFromCore, serializeJsonLd, structuredDataForEntity } from "@/lib/core/seo"
|
|
17
17
|
import { ecommerceItemFromProduct } from "@/lib/core/tracking"
|
|
18
18
|
import { storefrontCopy } from "@/lib/storefront-copy"
|
|
19
19
|
import { medusaLocale, STOREFRONT_ROUTES, storefrontLocale } from "@/lib/storefront-routes"
|
|
@@ -64,7 +64,7 @@ export default async function ProductPage({ params }: { params: Promise<{ countr
|
|
|
64
64
|
|
|
65
65
|
return (
|
|
66
66
|
<div className="stack page-section">
|
|
67
|
-
{jsonLd ? <script className="jsonld" type="application/ld+json" dangerouslySetInnerHTML={{ __html:
|
|
67
|
+
{jsonLd ? <script className="jsonld" type="application/ld+json" dangerouslySetInnerHTML={{ __html: serializeJsonLd(jsonLd) }} /> : null}
|
|
68
68
|
<ProductViewTracker analytics={config.analytics} googleAds={config.marketing.google_ads} item={tracking.item} googleAdsItem={remarketingItem} currency={tracking.currency} value={tracking.value} />
|
|
69
69
|
<Breadcrumbs
|
|
70
70
|
label={locale === "en" ? "Breadcrumb" : "Morzsanavigáció"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { metadataForPublicPage } from "@/lib/core/seo"
|
|
2
|
+
import { STOREFRONT_ROUTES } from "@/lib/storefront-routes"
|
|
1
3
|
import Link from "next/link"
|
|
2
4
|
import { ProductCard } from "@/components/product-card"
|
|
3
5
|
import { getCoreConfig } from "@/lib/core/client"
|
|
@@ -11,6 +13,19 @@ type SearchParams = Promise<{ q?: string; category?: string; sort?: string; page
|
|
|
11
13
|
type Params = Promise<{ countryCode: string }>
|
|
12
14
|
const sortMap: Record<string, string> = { newest: "-created_at", oldest: "created_at", name: "title" }
|
|
13
15
|
|
|
16
|
+
export async function generateMetadata({ params, searchParams }: { params: Params; searchParams: SearchParams }) {
|
|
17
|
+
const [config, route, query] = await Promise.all([getCoreConfig(), params, searchParams])
|
|
18
|
+
const locale = storefrontLocale(route.countryCode)
|
|
19
|
+
const copy = storefrontCopy(locale)
|
|
20
|
+
return metadataForPublicPage(config, {
|
|
21
|
+
path: STOREFRONT_ROUTES[locale].products,
|
|
22
|
+
locale,
|
|
23
|
+
title: copy.productsTitle,
|
|
24
|
+
description: copy.catalogDescription,
|
|
25
|
+
indexable: !query.q && !query.category && !query.sort && (!query.page || query.page === "1"),
|
|
26
|
+
})
|
|
27
|
+
}
|
|
28
|
+
|
|
14
29
|
export default async function ProductsPage({ params, searchParams }: { params: Params; searchParams: SearchParams }) {
|
|
15
30
|
const config = await getCoreConfig()
|
|
16
31
|
const { countryCode } = await params
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Metadata } from "next"
|
|
2
|
+
|
|
3
|
+
// Private, transactional and token-driven routes must never be indexed.
|
|
4
|
+
export const metadata: Metadata = {
|
|
5
|
+
robots: { index: false, follow: false },
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export default function PrivateRouteLayout({ children }: Readonly<{ children: React.ReactNode }>) {
|
|
9
|
+
return children
|
|
10
|
+
}
|
|
@@ -4,13 +4,20 @@ import { Breadcrumbs } from "@/components/breadcrumbs"
|
|
|
4
4
|
import { CmsEntryBody, CmsEntryMeta } from "@/components/cms-content"
|
|
5
5
|
import { cmsEntrySeo, getBlogPost } from "@/lib/core/cms"
|
|
6
6
|
import { requestStorefrontLocale } from "@/lib/storefront-locale-server"
|
|
7
|
-
import { STOREFRONT_ROUTES, medusaLocale } from "@/lib/storefront-routes"
|
|
7
|
+
import { STOREFRONT_ROUTES, medusaLocale, blogPostPath } from "@/lib/storefront-routes"
|
|
8
|
+
import { getCoreConfig } from "@/lib/core/client"
|
|
9
|
+
import { absoluteStorefrontUrl, serializeJsonLd } from "@/lib/core/seo"
|
|
8
10
|
|
|
9
11
|
export async function generateMetadata({ params }: { params: Promise<{ slug: string }> }): Promise<Metadata> {
|
|
10
12
|
const { slug } = await params
|
|
11
13
|
const locale = await requestStorefrontLocale()
|
|
12
14
|
const result = await getBlogPost(slug, { locale: medusaLocale(locale) }).catch(() => null)
|
|
13
|
-
|
|
15
|
+
if (!result) return { robots: { index: false, follow: false } }
|
|
16
|
+
const config = await getCoreConfig()
|
|
17
|
+
return cmsEntrySeo(result.entry, {
|
|
18
|
+
canonical: absoluteStorefrontUrl(config, blogPostPath(locale, slug)),
|
|
19
|
+
allowIndexing: config.seo.allow_indexing,
|
|
20
|
+
})
|
|
14
21
|
}
|
|
15
22
|
|
|
16
23
|
export default async function BlogPostPage({ params }: { params: Promise<{ slug: string }> }) {
|
|
@@ -20,9 +27,23 @@ export default async function BlogPostPage({ params }: { params: Promise<{ slug:
|
|
|
20
27
|
const result = await getBlogPost(slug, { locale: medusaLocale(locale) }).catch(() => null)
|
|
21
28
|
if (!result) notFound()
|
|
22
29
|
const entry = result.entry
|
|
30
|
+
const config = await getCoreConfig()
|
|
31
|
+
const canonical = entry.canonical_url || absoluteStorefrontUrl(config, blogPostPath(locale, slug))
|
|
32
|
+
const structuredData = {
|
|
33
|
+
"@context": "https://schema.org",
|
|
34
|
+
"@type": "BlogPosting",
|
|
35
|
+
...(canonical ? { mainEntityOfPage: canonical } : {}),
|
|
36
|
+
headline: entry.seo_title || entry.title,
|
|
37
|
+
...(entry.seo_description || entry.excerpt ? { description: entry.seo_description || entry.excerpt } : {}),
|
|
38
|
+
...(entry.published_at || entry.created_at ? { datePublished: entry.published_at || entry.created_at } : {}),
|
|
39
|
+
...(entry.updated_at ? { dateModified: entry.updated_at } : {}),
|
|
40
|
+
...(entry.featured_image_url ? { image: [entry.featured_image_url] } : {}),
|
|
41
|
+
...(entry.author_name ? { author: { "@type": "Person", name: entry.author_name } } : {}),
|
|
42
|
+
}
|
|
23
43
|
|
|
24
44
|
return (
|
|
25
45
|
<article className="stack page-section cms-detail">
|
|
46
|
+
<script type="application/ld+json" dangerouslySetInnerHTML={{ __html: serializeJsonLd(structuredData) }} />
|
|
26
47
|
<Breadcrumbs items={[{ label: english ? "Blog" : "Blog", href: STOREFRONT_ROUTES[locale].blog }, { label: entry.title }]} label={english ? "Breadcrumb" : "Morzsanavigáció"} />
|
|
27
48
|
<header className="stack-sm">
|
|
28
49
|
<CmsEntryMeta entry={entry} locale={locale} />
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { metadataForPublicPage } from "@/lib/core/seo"
|
|
2
|
+
import { getCoreConfig } from "@/lib/core/client"
|
|
1
3
|
import { CmsEntryCard } from "@/components/cms-content"
|
|
2
4
|
import { CmsTaxonomyFilters } from "@/components/cms-taxonomy-filters"
|
|
3
5
|
import { cmsConfig, listBlogPosts, listCmsTaxonomy } from "@/lib/core/cms"
|
|
@@ -8,6 +10,17 @@ type PageProps = {
|
|
|
8
10
|
searchParams: Promise<Record<string, string | string[] | undefined>>
|
|
9
11
|
}
|
|
10
12
|
|
|
13
|
+
export async function generateMetadata({ searchParams }: PageProps) {
|
|
14
|
+
const [config, locale, query] = await Promise.all([getCoreConfig(), requestStorefrontLocale(), searchParams])
|
|
15
|
+
return metadataForPublicPage(config, {
|
|
16
|
+
path: STOREFRONT_ROUTES[locale].blog,
|
|
17
|
+
locale,
|
|
18
|
+
title: "Blog",
|
|
19
|
+
description: locale === "en" ? "News, guides and useful content from the store." : "Hírek, útmutatók és hasznos tartalmak a webáruháztól.",
|
|
20
|
+
indexable: !query.category && !query.tag,
|
|
21
|
+
})
|
|
22
|
+
}
|
|
23
|
+
|
|
11
24
|
export default async function BlogPage({ searchParams }: PageProps) {
|
|
12
25
|
const [locale, params] = await Promise.all([
|
|
13
26
|
requestStorefrontLocale(),
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Metadata } from "next"
|
|
2
|
+
|
|
3
|
+
// Private, transactional and token-driven routes must never be indexed.
|
|
4
|
+
export const metadata: Metadata = {
|
|
5
|
+
robots: { index: false, follow: false },
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export default function PrivateRouteLayout({ children }: Readonly<{ children: React.ReactNode }>) {
|
|
9
|
+
return children
|
|
10
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Metadata } from "next"
|
|
2
|
+
|
|
3
|
+
// Private, transactional and token-driven routes must never be indexed.
|
|
4
|
+
export const metadata: Metadata = {
|
|
5
|
+
robots: { index: false, follow: false },
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export default function PrivateRouteLayout({ children }: Readonly<{ children: React.ReactNode }>) {
|
|
9
|
+
return children
|
|
10
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Metadata } from "next"
|
|
2
|
+
|
|
3
|
+
// Private, transactional and token-driven routes must never be indexed.
|
|
4
|
+
export const metadata: Metadata = {
|
|
5
|
+
robots: { index: false, follow: false },
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export default function PrivateRouteLayout({ children }: Readonly<{ children: React.ReactNode }>) {
|
|
9
|
+
return children
|
|
10
|
+
}
|
|
@@ -1,7 +1,20 @@
|
|
|
1
|
+
import { metadataForPublicPage } from "@/lib/core/seo"
|
|
2
|
+
import { getCoreConfig } from "@/lib/core/client"
|
|
3
|
+
import { STOREFRONT_ROUTES } from "@/lib/storefront-routes"
|
|
1
4
|
import { LeadForm } from "@/components/lead-form"
|
|
2
5
|
import { leadFormConfig } from "@/lib/core/leads"
|
|
3
6
|
import { requestStorefrontLocale } from "@/lib/storefront-locale-server"
|
|
4
7
|
|
|
8
|
+
export async function generateMetadata() {
|
|
9
|
+
const [config, locale] = await Promise.all([getCoreConfig(), requestStorefrontLocale()])
|
|
10
|
+
return metadataForPublicPage(config, {
|
|
11
|
+
path: STOREFRONT_ROUTES[locale].contact,
|
|
12
|
+
locale,
|
|
13
|
+
title: locale === "en" ? "Contact" : "Kapcsolat",
|
|
14
|
+
description: locale === "en" ? "Contact our team." : "Lépj kapcsolatba velünk.",
|
|
15
|
+
})
|
|
16
|
+
}
|
|
17
|
+
|
|
5
18
|
export default async function ContactPage() {
|
|
6
19
|
const locale = await requestStorefrontLocale()
|
|
7
20
|
const english = locale === "en"
|
|
@@ -1,11 +1,19 @@
|
|
|
1
|
+
import { metadataForPublicPage } from "@/lib/core/seo"
|
|
2
|
+
import { getCoreConfig } from "@/lib/core/client"
|
|
3
|
+
import { STOREFRONT_ROUTES } from "@/lib/storefront-routes"
|
|
1
4
|
import { DocumentList } from "@/components/document-list"
|
|
2
5
|
import { getDocuments } from "@/lib/core/documents"
|
|
3
6
|
import { requestStorefrontLocale } from "@/lib/storefront-locale-server"
|
|
4
7
|
import { medusaLocale } from "@/lib/storefront-routes"
|
|
5
8
|
|
|
6
9
|
export async function generateMetadata() {
|
|
7
|
-
const locale = await requestStorefrontLocale()
|
|
8
|
-
return {
|
|
10
|
+
const [config, locale] = await Promise.all([getCoreConfig(), requestStorefrontLocale()])
|
|
11
|
+
return metadataForPublicPage(config, {
|
|
12
|
+
path: STOREFRONT_ROUTES[locale].documents,
|
|
13
|
+
locale,
|
|
14
|
+
title: locale === "en" ? "Documents" : "Dokumentumok",
|
|
15
|
+
description: locale === "en" ? "Documents published by the store." : "A webáruház által közzétett dokumentumok.",
|
|
16
|
+
})
|
|
9
17
|
}
|
|
10
18
|
|
|
11
19
|
export default async function DocumentsPage() {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Metadata } from "next"
|
|
2
|
+
|
|
3
|
+
// Private, transactional and token-driven routes must never be indexed.
|
|
4
|
+
export const metadata: Metadata = {
|
|
5
|
+
robots: { index: false, follow: false },
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export default function PrivateRouteLayout({ children }: Readonly<{ children: React.ReactNode }>) {
|
|
9
|
+
return children
|
|
10
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Metadata } from "next"
|
|
2
|
+
|
|
3
|
+
// Private, transactional and token-driven routes must never be indexed.
|
|
4
|
+
export const metadata: Metadata = {
|
|
5
|
+
robots: { index: false, follow: false },
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export default function PrivateRouteLayout({ children }: Readonly<{ children: React.ReactNode }>) {
|
|
9
|
+
return children
|
|
10
|
+
}
|
|
@@ -4,13 +4,20 @@ import { Breadcrumbs } from "@/components/breadcrumbs"
|
|
|
4
4
|
import { CmsEntryBody, CmsEntryMeta } from "@/components/cms-content"
|
|
5
5
|
import { cmsEntrySeo, getKnowledgeBaseEntry } from "@/lib/core/cms"
|
|
6
6
|
import { requestStorefrontLocale } from "@/lib/storefront-locale-server"
|
|
7
|
-
import { STOREFRONT_ROUTES, medusaLocale } from "@/lib/storefront-routes"
|
|
7
|
+
import { STOREFRONT_ROUTES, medusaLocale, knowledgeBasePath } from "@/lib/storefront-routes"
|
|
8
|
+
import { getCoreConfig } from "@/lib/core/client"
|
|
9
|
+
import { absoluteStorefrontUrl, serializeJsonLd } from "@/lib/core/seo"
|
|
8
10
|
|
|
9
11
|
export async function generateMetadata({ params }: { params: Promise<{ slug: string }> }): Promise<Metadata> {
|
|
10
12
|
const { slug } = await params
|
|
11
13
|
const locale = await requestStorefrontLocale()
|
|
12
14
|
const result = await getKnowledgeBaseEntry(slug, { locale: medusaLocale(locale) }).catch(() => null)
|
|
13
|
-
|
|
15
|
+
if (!result) return { robots: { index: false, follow: false } }
|
|
16
|
+
const config = await getCoreConfig()
|
|
17
|
+
return cmsEntrySeo(result.entry, {
|
|
18
|
+
canonical: absoluteStorefrontUrl(config, knowledgeBasePath(locale, slug)),
|
|
19
|
+
allowIndexing: config.seo.allow_indexing,
|
|
20
|
+
})
|
|
14
21
|
}
|
|
15
22
|
|
|
16
23
|
export default async function KnowledgeBaseEntryPage({ params }: { params: Promise<{ slug: string }> }) {
|
|
@@ -20,9 +27,23 @@ export default async function KnowledgeBaseEntryPage({ params }: { params: Promi
|
|
|
20
27
|
const result = await getKnowledgeBaseEntry(slug, { locale: medusaLocale(locale) }).catch(() => null)
|
|
21
28
|
if (!result) notFound()
|
|
22
29
|
const entry = result.entry
|
|
30
|
+
const config = await getCoreConfig()
|
|
31
|
+
const canonical = entry.canonical_url || absoluteStorefrontUrl(config, knowledgeBasePath(locale, slug))
|
|
32
|
+
const structuredData = {
|
|
33
|
+
"@context": "https://schema.org",
|
|
34
|
+
"@type": "Article",
|
|
35
|
+
...(canonical ? { mainEntityOfPage: canonical } : {}),
|
|
36
|
+
headline: entry.seo_title || entry.title,
|
|
37
|
+
...(entry.seo_description || entry.excerpt ? { description: entry.seo_description || entry.excerpt } : {}),
|
|
38
|
+
...(entry.published_at || entry.created_at ? { datePublished: entry.published_at || entry.created_at } : {}),
|
|
39
|
+
...(entry.updated_at ? { dateModified: entry.updated_at } : {}),
|
|
40
|
+
...(entry.featured_image_url ? { image: [entry.featured_image_url] } : {}),
|
|
41
|
+
...(entry.author_name ? { author: { "@type": "Person", name: entry.author_name } } : {}),
|
|
42
|
+
}
|
|
23
43
|
|
|
24
44
|
return (
|
|
25
45
|
<article className="stack page-section cms-detail">
|
|
46
|
+
<script type="application/ld+json" dangerouslySetInnerHTML={{ __html: serializeJsonLd(structuredData) }} />
|
|
26
47
|
<Breadcrumbs items={[{ label: english ? "Knowledge base" : "Tudástár", href: STOREFRONT_ROUTES[locale].knowledgeBase }, { label: entry.title }]} label={english ? "Breadcrumb" : "Morzsanavigáció"} />
|
|
27
48
|
<header className="stack-sm">
|
|
28
49
|
<CmsEntryMeta entry={entry} locale={locale} />
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { metadataForPublicPage } from "@/lib/core/seo"
|
|
2
|
+
import { getCoreConfig } from "@/lib/core/client"
|
|
1
3
|
import { CmsEntryCard } from "@/components/cms-content"
|
|
2
4
|
import { CmsTaxonomyFilters } from "@/components/cms-taxonomy-filters"
|
|
3
5
|
import { cmsConfig, listCmsTaxonomy, listKnowledgeBaseEntries } from "@/lib/core/cms"
|
|
@@ -8,6 +10,17 @@ type PageProps = {
|
|
|
8
10
|
searchParams: Promise<Record<string, string | string[] | undefined>>
|
|
9
11
|
}
|
|
10
12
|
|
|
13
|
+
export async function generateMetadata({ searchParams }: PageProps) {
|
|
14
|
+
const [config, locale, query] = await Promise.all([getCoreConfig(), requestStorefrontLocale(), searchParams])
|
|
15
|
+
return metadataForPublicPage(config, {
|
|
16
|
+
path: STOREFRONT_ROUTES[locale].knowledgeBase,
|
|
17
|
+
locale,
|
|
18
|
+
title: locale === "en" ? "Knowledge base" : "Tudástár",
|
|
19
|
+
description: locale === "en" ? "Answers, guides and practical information." : "Válaszok, útmutatók és gyakorlati információk.",
|
|
20
|
+
indexable: !query.category && !query.tag,
|
|
21
|
+
})
|
|
22
|
+
}
|
|
23
|
+
|
|
11
24
|
export default async function KnowledgeBasePage({ searchParams }: PageProps) {
|
|
12
25
|
const [locale, params] = await Promise.all([
|
|
13
26
|
requestStorefrontLocale(),
|
|
@@ -16,6 +16,7 @@ import { NewsletterSignup } from "@/components/newsletter-signup"
|
|
|
16
16
|
import { StorefrontHeader } from "@/components/storefront-header"
|
|
17
17
|
import { ToastProvider } from "@/components/toast-provider"
|
|
18
18
|
import { getCoreConfig } from "@/lib/core/client"
|
|
19
|
+
import { getStructuredData, serializeJsonLd } from "@/lib/core/seo"
|
|
19
20
|
import { getLegalEmbed, type LegalEmbedConfig } from "@/lib/core/legal"
|
|
20
21
|
import { requestStorefrontLocale } from "@/lib/storefront-locale-server"
|
|
21
22
|
import { STOREFRONT_ROUTES } from "@/lib/storefront-routes"
|
|
@@ -35,6 +36,7 @@ window.gtag('consent', 'default', {
|
|
|
35
36
|
export async function generateMetadata(): Promise<Metadata> {
|
|
36
37
|
const config = await getCoreConfig()
|
|
37
38
|
return {
|
|
39
|
+
metadataBase: config.seo.storefront_url ? new URL(config.seo.storefront_url) : undefined,
|
|
38
40
|
title: {
|
|
39
41
|
default: config.store.name,
|
|
40
42
|
template: `%s | ${config.store.name}`,
|
|
@@ -56,11 +58,15 @@ export default async function RootLayout({ children }: Readonly<{ children: Reac
|
|
|
56
58
|
])
|
|
57
59
|
const routes = STOREFRONT_ROUTES[locale]
|
|
58
60
|
const en = locale === "en"
|
|
61
|
+
const siteJsonLd = config.seo.enabled
|
|
62
|
+
? await getStructuredData(config, { type: "site" }).catch(() => null)
|
|
63
|
+
: null
|
|
59
64
|
|
|
60
65
|
return (
|
|
61
66
|
<html lang={locale}>
|
|
62
67
|
<head><script dangerouslySetInnerHTML={{ __html: consentDefaultScript }} /></head>
|
|
63
68
|
<body>
|
|
69
|
+
{siteJsonLd ? <script type="application/ld+json" dangerouslySetInnerHTML={{ __html: serializeJsonLd(siteJsonLd) }} /> : null}
|
|
64
70
|
<AccessibilityPreferencesProvider>
|
|
65
71
|
<ToastProvider locale={locale}>
|
|
66
72
|
<CartProvider config={config}>
|
|
@@ -1,9 +1,22 @@
|
|
|
1
|
+
import { metadataForPublicPage } from "@/lib/core/seo"
|
|
2
|
+
import { STOREFRONT_ROUTES } from "@/lib/storefront-routes"
|
|
1
3
|
import { FogyasztobaratEmbed } from "@/components/fogyasztobarat-embed"
|
|
2
4
|
import { getCoreConfig } from "@/lib/core/client"
|
|
3
5
|
import { getLegalEmbed, listLegalDocuments, type LegalEmbedConfig } from "@/lib/core/legal"
|
|
4
6
|
import { storefrontCopy } from "@/lib/storefront-copy"
|
|
5
7
|
import { requestStorefrontLocale } from "@/lib/storefront-locale-server"
|
|
6
8
|
|
|
9
|
+
export async function generateMetadata() {
|
|
10
|
+
const [config, locale] = await Promise.all([getCoreConfig(), requestStorefrontLocale()])
|
|
11
|
+
const copy = storefrontCopy(locale)
|
|
12
|
+
return metadataForPublicPage(config, {
|
|
13
|
+
path: STOREFRONT_ROUTES[locale].legal,
|
|
14
|
+
locale,
|
|
15
|
+
title: copy.legalTitle,
|
|
16
|
+
description: copy.legalDescription,
|
|
17
|
+
})
|
|
18
|
+
}
|
|
19
|
+
|
|
7
20
|
export default async function LegalPage() {
|
|
8
21
|
const [config, locale] = await Promise.all([
|
|
9
22
|
getCoreConfig(),
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Metadata } from "next"
|
|
2
|
+
|
|
3
|
+
// Private, transactional and token-driven routes must never be indexed.
|
|
4
|
+
export const metadata: Metadata = {
|
|
5
|
+
robots: { index: false, follow: false },
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export default function PrivateRouteLayout({ children }: Readonly<{ children: React.ReactNode }>) {
|
|
9
|
+
return children
|
|
10
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { metadataForPublicPage } from "@/lib/core/seo"
|
|
1
2
|
import Link from "next/link"
|
|
2
3
|
import { ProductCard } from "@/components/product-card"
|
|
3
4
|
import { getCoreConfig } from "@/lib/core/client"
|
|
@@ -13,6 +14,16 @@ import { storefrontCopy } from "@/lib/storefront-copy"
|
|
|
13
14
|
import { requestStorefrontLocale } from "@/lib/storefront-locale-server"
|
|
14
15
|
import { categoryPath, medusaLocale, STOREFRONT_ROUTES } from "@/lib/storefront-routes"
|
|
15
16
|
|
|
17
|
+
export async function generateMetadata() {
|
|
18
|
+
const [config, locale] = await Promise.all([getCoreConfig(), requestStorefrontLocale()])
|
|
19
|
+
return metadataForPublicPage(config, {
|
|
20
|
+
path: STOREFRONT_ROUTES[locale].home,
|
|
21
|
+
locale,
|
|
22
|
+
title: config.store.name,
|
|
23
|
+
description: storefrontCopy(locale).homeHeroText,
|
|
24
|
+
})
|
|
25
|
+
}
|
|
26
|
+
|
|
16
27
|
export default async function HomePage() {
|
|
17
28
|
const config = await getCoreConfig()
|
|
18
29
|
const locale = await requestStorefrontLocale()
|
|
@@ -4,13 +4,20 @@ import { Breadcrumbs } from "@/components/breadcrumbs"
|
|
|
4
4
|
import { CmsEntryBody } from "@/components/cms-content"
|
|
5
5
|
import { cmsEntrySeo, getCmsPage } from "@/lib/core/cms"
|
|
6
6
|
import { requestStorefrontLocale } from "@/lib/storefront-locale-server"
|
|
7
|
-
import { STOREFRONT_ROUTES, medusaLocale } from "@/lib/storefront-routes"
|
|
7
|
+
import { STOREFRONT_ROUTES, medusaLocale, cmsPagePath } from "@/lib/storefront-routes"
|
|
8
|
+
import { getCoreConfig } from "@/lib/core/client"
|
|
9
|
+
import { absoluteStorefrontUrl, serializeJsonLd } from "@/lib/core/seo"
|
|
8
10
|
|
|
9
11
|
export async function generateMetadata({ params }: { params: Promise<{ slug: string }> }): Promise<Metadata> {
|
|
10
12
|
const { slug } = await params
|
|
11
13
|
const locale = await requestStorefrontLocale()
|
|
12
14
|
const result = await getCmsPage(slug, { locale: medusaLocale(locale) }).catch(() => null)
|
|
13
|
-
|
|
15
|
+
if (!result) return { robots: { index: false, follow: false } }
|
|
16
|
+
const config = await getCoreConfig()
|
|
17
|
+
return cmsEntrySeo(result.entry, {
|
|
18
|
+
canonical: absoluteStorefrontUrl(config, cmsPagePath(locale, slug)),
|
|
19
|
+
allowIndexing: config.seo.allow_indexing,
|
|
20
|
+
})
|
|
14
21
|
}
|
|
15
22
|
|
|
16
23
|
export default async function CmsPage({ params }: { params: Promise<{ slug: string }> }) {
|
|
@@ -20,9 +27,23 @@ export default async function CmsPage({ params }: { params: Promise<{ slug: stri
|
|
|
20
27
|
const result = await getCmsPage(slug, { locale: medusaLocale(locale) }).catch(() => null)
|
|
21
28
|
if (!result) notFound()
|
|
22
29
|
const entry = result.entry
|
|
30
|
+
const config = await getCoreConfig()
|
|
31
|
+
const canonical = entry.canonical_url || absoluteStorefrontUrl(config, cmsPagePath(locale, slug))
|
|
32
|
+
const structuredData = {
|
|
33
|
+
"@context": "https://schema.org",
|
|
34
|
+
"@type": "WebPage",
|
|
35
|
+
...(canonical ? { mainEntityOfPage: canonical } : {}),
|
|
36
|
+
headline: entry.seo_title || entry.title,
|
|
37
|
+
...(entry.seo_description || entry.excerpt ? { description: entry.seo_description || entry.excerpt } : {}),
|
|
38
|
+
...(entry.published_at || entry.created_at ? { datePublished: entry.published_at || entry.created_at } : {}),
|
|
39
|
+
...(entry.updated_at ? { dateModified: entry.updated_at } : {}),
|
|
40
|
+
...(entry.featured_image_url ? { image: [entry.featured_image_url] } : {}),
|
|
41
|
+
...(entry.author_name ? { author: { "@type": "Person", name: entry.author_name } } : {}),
|
|
42
|
+
}
|
|
23
43
|
|
|
24
44
|
return (
|
|
25
45
|
<article className="stack page-section cms-detail">
|
|
46
|
+
<script type="application/ld+json" dangerouslySetInnerHTML={{ __html: serializeJsonLd(structuredData) }} />
|
|
26
47
|
<Breadcrumbs items={[{ label: english ? "Pages" : "Oldalak", href: STOREFRONT_ROUTES[locale].home }, { label: entry.title }]} label={english ? "Breadcrumb" : "Morzsanavigáció"} />
|
|
27
48
|
<header className="stack-sm">
|
|
28
49
|
<h1>{entry.title}</h1>
|
|
@@ -1,8 +1,21 @@
|
|
|
1
|
+
import { metadataForPublicPage } from "@/lib/core/seo"
|
|
2
|
+
import { getCoreConfig } from "@/lib/core/client"
|
|
3
|
+
import { STOREFRONT_ROUTES } from "@/lib/storefront-routes"
|
|
1
4
|
import { CmsEntryCard } from "@/components/cms-content"
|
|
2
5
|
import { listCmsPages } from "@/lib/core/cms"
|
|
3
6
|
import { requestStorefrontLocale } from "@/lib/storefront-locale-server"
|
|
4
7
|
import { cmsPagePath, medusaLocale } from "@/lib/storefront-routes"
|
|
5
8
|
|
|
9
|
+
export async function generateMetadata() {
|
|
10
|
+
const [config, locale] = await Promise.all([getCoreConfig(), requestStorefrontLocale()])
|
|
11
|
+
return metadataForPublicPage(config, {
|
|
12
|
+
path: STOREFRONT_ROUTES[locale].cmsPages,
|
|
13
|
+
locale,
|
|
14
|
+
title: locale === "en" ? "Information" : "Információk",
|
|
15
|
+
description: locale === "en" ? "Information published by the store." : "A webáruház által közzétett tájékoztatók.",
|
|
16
|
+
})
|
|
17
|
+
}
|
|
18
|
+
|
|
6
19
|
export default async function CmsPagesIndex() {
|
|
7
20
|
const locale = await requestStorefrontLocale()
|
|
8
21
|
const english = locale === "en"
|
|
@@ -1,7 +1,20 @@
|
|
|
1
|
+
import { metadataForPublicPage } from "@/lib/core/seo"
|
|
2
|
+
import { getCoreConfig } from "@/lib/core/client"
|
|
3
|
+
import { STOREFRONT_ROUTES } from "@/lib/storefront-routes"
|
|
1
4
|
import { QuoteRequestForm } from "@/components/quote-request-form"
|
|
2
5
|
import { quoteRequestConfig } from "@/lib/core/quotes"
|
|
3
6
|
import { requestStorefrontLocale } from "@/lib/storefront-locale-server"
|
|
4
7
|
|
|
8
|
+
export async function generateMetadata() {
|
|
9
|
+
const [config, locale] = await Promise.all([getCoreConfig(), requestStorefrontLocale()])
|
|
10
|
+
return metadataForPublicPage(config, {
|
|
11
|
+
path: STOREFRONT_ROUTES[locale].quoteRequest,
|
|
12
|
+
locale,
|
|
13
|
+
title: locale === "en" ? "Request a quote" : "Ajánlatkérés",
|
|
14
|
+
description: locale === "en" ? "Request a tailored business offer." : "Kérj személyre szabott ajánlatot.",
|
|
15
|
+
})
|
|
16
|
+
}
|
|
17
|
+
|
|
5
18
|
export default async function QuoteRequestPage() {
|
|
6
19
|
const locale = await requestStorefrontLocale()
|
|
7
20
|
const english = locale === "en"
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Metadata } from "next"
|
|
2
|
+
|
|
3
|
+
// Private, transactional and token-driven routes must never be indexed.
|
|
4
|
+
export const metadata: Metadata = {
|
|
5
|
+
robots: { index: false, follow: false },
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export default function PrivateRouteLayout({ children }: Readonly<{ children: React.ReactNode }>) {
|
|
9
|
+
return children
|
|
10
|
+
}
|
|
@@ -12,6 +12,9 @@ export async function GET() {
|
|
|
12
12
|
})
|
|
13
13
|
return new Response(await response.text(), {
|
|
14
14
|
status: response.status,
|
|
15
|
-
headers: {
|
|
15
|
+
headers: {
|
|
16
|
+
"content-type": response.headers.get("content-type") || "text/plain; charset=utf-8",
|
|
17
|
+
"cache-control": response.ok ? "public, max-age=300, stale-while-revalidate=900" : "no-store",
|
|
18
|
+
},
|
|
16
19
|
})
|
|
17
20
|
}
|
|
@@ -1,17 +1,33 @@
|
|
|
1
1
|
import { getCoreConfig, medusaRawFetch } from "@/lib/core/client"
|
|
2
|
+
import { parseSitemapPage, sitemapSourcePath } from "@/lib/core/seo-output"
|
|
2
3
|
|
|
3
4
|
// The Medusa backend is not running during a fresh webshop's Next.js build.
|
|
4
5
|
// Resolve the SEO contract at request time so build never fetches live API data.
|
|
5
6
|
export const dynamic = "force-dynamic"
|
|
6
7
|
|
|
7
|
-
export async function GET() {
|
|
8
|
+
export async function GET(request: Request) {
|
|
8
9
|
const config = await getCoreConfig()
|
|
9
|
-
|
|
10
|
+
let page: number | null
|
|
11
|
+
try {
|
|
12
|
+
page = parseSitemapPage(request.url)
|
|
13
|
+
} catch {
|
|
14
|
+
return new Response("Invalid sitemap page", {
|
|
15
|
+
status: 400,
|
|
16
|
+
headers: { "cache-control": "no-store" },
|
|
17
|
+
})
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const response = await medusaRawFetch(sitemapSourcePath(config.seo.sitemap_source_endpoint, page), {
|
|
10
21
|
next: { revalidate: 300 },
|
|
11
22
|
headers: { accept: "application/xml,text/xml" },
|
|
12
23
|
})
|
|
13
24
|
return new Response(await response.text(), {
|
|
14
25
|
status: response.status,
|
|
15
|
-
headers: {
|
|
26
|
+
headers: {
|
|
27
|
+
"content-type": response.headers.get("content-type") || "application/xml; charset=utf-8",
|
|
28
|
+
"cache-control": response.ok
|
|
29
|
+
? "public, max-age=300, stale-while-revalidate=900"
|
|
30
|
+
: "no-store",
|
|
31
|
+
},
|
|
16
32
|
})
|
|
17
33
|
}
|
|
@@ -522,12 +522,16 @@ export function CheckoutFlow({ config }: { config: CoreConfig }) {
|
|
|
522
522
|
setError(null)
|
|
523
523
|
}
|
|
524
524
|
|
|
525
|
-
/** Reconcile
|
|
525
|
+
/** Reconcile widget points where another backend catalog lookup is required. */
|
|
526
526
|
const verifyCarrierPickupPoint = async (kind: PickupKind, picked: CarrierPickupPoint | null) => {
|
|
527
527
|
if (!kind || !picked || kind !== picked.provider) return picked
|
|
528
|
+
// GLS <gls-dpm> selects from the official live feed itself. Re-fetching the
|
|
529
|
+
// entire catalog via Core can independently fail with HTTP 503 and block
|
|
530
|
+
// checkout after a valid selection. Core still validates the saved point
|
|
531
|
+
// and verifies it with GLS again before generating a shipping label.
|
|
532
|
+
if (kind === "gls") return picked
|
|
528
533
|
let candidates: JsonRecord[] | null = null
|
|
529
534
|
if (kind === "foxpost") candidates = (await api.foxpostLockers()).lockers
|
|
530
|
-
if (kind === "gls") candidates = (await api.glsDeliveryPoints()).deliveryPoints
|
|
531
535
|
if (kind === "mpl") {
|
|
532
536
|
candidates = (await api.mplDeliveryPlaces({ postCode: picked.postalCode })).deliveryPlaces
|
|
533
537
|
}
|
|
@@ -154,15 +154,17 @@ export function listCmsTaxonomy(options: { taxonomy?: "category" | "tag"; locale
|
|
|
154
154
|
)
|
|
155
155
|
}
|
|
156
156
|
|
|
157
|
-
export function cmsEntrySeo(entry: CmsEntry): Metadata {
|
|
157
|
+
export function cmsEntrySeo(entry: CmsEntry, options: { canonical?: string; allowIndexing?: boolean } = {}): Metadata {
|
|
158
158
|
const image = entry.og_image_url || entry.featured_image_url || undefined
|
|
159
|
+
const canonical = entry.canonical_url || options.canonical
|
|
159
160
|
|
|
160
161
|
return {
|
|
161
162
|
title: entry.seo_title || entry.title,
|
|
162
163
|
description: entry.seo_description || entry.excerpt || undefined,
|
|
163
|
-
alternates:
|
|
164
|
-
robots: entry.noindex
|
|
164
|
+
alternates: canonical ? { canonical } : undefined,
|
|
165
|
+
robots: { index: !entry.noindex && options.allowIndexing !== false, follow: !entry.noindex },
|
|
165
166
|
openGraph: {
|
|
167
|
+
url: canonical,
|
|
166
168
|
title: entry.seo_title || entry.title,
|
|
167
169
|
description: entry.seo_description || entry.excerpt || undefined,
|
|
168
170
|
images: image ? [image] : undefined,
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** Pure SEO output helpers shared by Next routes and regression tests. */
|
|
2
|
+
export function parseSitemapPage(url: string): number | null {
|
|
3
|
+
const raw = new URL(url).searchParams.get("page")
|
|
4
|
+
if (raw === null) return null
|
|
5
|
+
if (!/^[1-9]\d*$/.test(raw) || !Number.isSafeInteger(Number(raw))) {
|
|
6
|
+
throw new Error("Invalid sitemap page")
|
|
7
|
+
}
|
|
8
|
+
return Number(raw)
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function sitemapSourcePath(sourceEndpoint: string, page: number | null): string {
|
|
12
|
+
const source = new URL(sourceEndpoint, "http://core.internal")
|
|
13
|
+
if (page !== null) source.searchParams.set("page", String(page))
|
|
14
|
+
return `${source.pathname}${source.search}`
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function serializeJsonLd(value: unknown): string {
|
|
18
|
+
// A product or CMS title containing </script> must never terminate this tag.
|
|
19
|
+
return JSON.stringify(value).replace(/</g, "\\u003c")
|
|
20
|
+
}
|
|
@@ -3,9 +3,11 @@ import { medusaFetch } from "./client"
|
|
|
3
3
|
import type { CoreConfig, SeoContractResponse } from "./types"
|
|
4
4
|
import {
|
|
5
5
|
categoryPath,
|
|
6
|
+
equivalentLocalePath,
|
|
6
7
|
medusaLocale,
|
|
7
8
|
productPath,
|
|
8
9
|
storefrontLocale,
|
|
10
|
+
type StorefrontLocale,
|
|
9
11
|
} from "@/lib/storefront-routes"
|
|
10
12
|
|
|
11
13
|
type SeoEntityQuery = {
|
|
@@ -85,7 +87,12 @@ export async function metadataFromCore(
|
|
|
85
87
|
locale,
|
|
86
88
|
})
|
|
87
89
|
const metadata = toNextMetadata(response, config)
|
|
88
|
-
const
|
|
90
|
+
const expectedCanonical = absoluteStorefrontUrl(config, (
|
|
91
|
+
query.type === "product" ? productPath : categoryPath
|
|
92
|
+
)(publicLocale, query.handle))
|
|
93
|
+
const languages = !response.contract.canonical || response.contract.canonical === expectedCanonical
|
|
94
|
+
? localizedAlternates(config, query)
|
|
95
|
+
: undefined
|
|
89
96
|
|
|
90
97
|
return {
|
|
91
98
|
...metadata,
|
|
@@ -109,18 +116,97 @@ export async function structuredDataForEntity(
|
|
|
109
116
|
})
|
|
110
117
|
}
|
|
111
118
|
|
|
112
|
-
function
|
|
119
|
+
export function absoluteStorefrontUrl(config: CoreConfig, path: string): string | undefined {
|
|
113
120
|
const base = config.seo.storefront_url
|
|
114
121
|
if (!base) return undefined
|
|
122
|
+
try {
|
|
123
|
+
return new URL(path, base).toString()
|
|
124
|
+
} catch {
|
|
125
|
+
return undefined
|
|
126
|
+
}
|
|
127
|
+
}
|
|
115
128
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
129
|
+
/**
|
|
130
|
+
* Metadata for public landing/listing pages. An explicit Core seo_page override
|
|
131
|
+
* wins, but pages are still canonicalized when no admin override exists.
|
|
132
|
+
*/
|
|
133
|
+
export async function metadataForPublicPage(
|
|
134
|
+
config: CoreConfig,
|
|
135
|
+
input: {
|
|
136
|
+
path: string
|
|
137
|
+
locale: StorefrontLocale
|
|
138
|
+
title: string
|
|
139
|
+
description?: string
|
|
140
|
+
indexable?: boolean
|
|
141
|
+
},
|
|
142
|
+
): Promise<Metadata> {
|
|
143
|
+
const canonical = absoluteStorefrontUrl(config, input.path)
|
|
144
|
+
const fallback: Metadata = {
|
|
145
|
+
title: input.title,
|
|
146
|
+
description: input.description,
|
|
147
|
+
alternates: canonical ? { canonical } : undefined,
|
|
148
|
+
robots: {
|
|
149
|
+
index: config.seo.allow_indexing && input.indexable !== false,
|
|
150
|
+
follow: true, // filtered/paginated lists remain crawlable, but not indexable
|
|
151
|
+
},
|
|
152
|
+
openGraph: {
|
|
153
|
+
title: input.title,
|
|
154
|
+
description: input.description,
|
|
155
|
+
url: canonical,
|
|
156
|
+
siteName: config.seo.store_name,
|
|
157
|
+
},
|
|
158
|
+
}
|
|
159
|
+
if (!config.seo.enabled) return fallback
|
|
120
160
|
|
|
161
|
+
const resolved = await getSeoContract(config, {
|
|
162
|
+
type: "page",
|
|
163
|
+
path: input.path,
|
|
164
|
+
locale: medusaLocale(input.locale),
|
|
165
|
+
}).catch(() => null)
|
|
166
|
+
|
|
167
|
+
const override = resolved ? toNextMetadata(resolved, config) : null
|
|
168
|
+
const languages = localizedStaticAlternates(config, input.path, input.locale)
|
|
121
169
|
return {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
170
|
+
...fallback,
|
|
171
|
+
...(override || {}),
|
|
172
|
+
title: override?.title || fallback.title,
|
|
173
|
+
description: override?.description || fallback.description,
|
|
174
|
+
alternates: {
|
|
175
|
+
...(canonical ? { canonical } : {}),
|
|
176
|
+
...(override?.alternates || {}),
|
|
177
|
+
...(languages && (!override?.alternates?.canonical || override.alternates.canonical === canonical)
|
|
178
|
+
? { languages }
|
|
179
|
+
: {}),
|
|
180
|
+
},
|
|
181
|
+
robots: input.indexable === false
|
|
182
|
+
? { index: false, follow: true }
|
|
183
|
+
: override?.robots || fallback.robots,
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
function localizedStaticAlternates(config: CoreConfig, path: string, locale: StorefrontLocale) {
|
|
188
|
+
const supported = Array.from(new Set(config.seo.supported_locales || [locale]))
|
|
189
|
+
if (supported.length < 2) return undefined
|
|
190
|
+
const languages: Record<string, string> = {}
|
|
191
|
+
for (const item of supported) {
|
|
192
|
+
const url = absoluteStorefrontUrl(config, equivalentLocalePath(path, item))
|
|
193
|
+
if (url) languages[item === "hu" ? "hu-HU" : "en-US"] = url
|
|
125
194
|
}
|
|
195
|
+
if (languages["hu-HU"]) languages["x-default"] = languages["hu-HU"]
|
|
196
|
+
return Object.keys(languages).length > 1 ? languages : undefined
|
|
126
197
|
}
|
|
198
|
+
|
|
199
|
+
function localizedAlternates(config: CoreConfig, query: SeoEntityQuery) {
|
|
200
|
+
const supported = Array.from(new Set(config.seo.supported_locales || []))
|
|
201
|
+
if (supported.length < 2) return undefined
|
|
202
|
+
const pathFor = query.type === "product" ? productPath : categoryPath
|
|
203
|
+
const languages: Record<string, string> = {}
|
|
204
|
+
for (const locale of supported) {
|
|
205
|
+
const url = absoluteStorefrontUrl(config, pathFor(locale, query.handle))
|
|
206
|
+
if (url) languages[locale === "hu" ? "hu-HU" : "en-US"] = url
|
|
207
|
+
}
|
|
208
|
+
if (languages["hu-HU"]) languages["x-default"] = languages["hu-HU"]
|
|
209
|
+
return Object.keys(languages).length > 1 ? languages : undefined
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
export { serializeJsonLd } from "./seo-output"
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
const LOCALE_COOKIE = "hszrdm_storefront_locale"
|
|
9
9
|
const LOCALE_HEADER = "x-hszrdm-storefront-locale"
|
|
10
10
|
|
|
11
|
-
export function proxy(request: NextRequest) {
|
|
11
|
+
export async function proxy(request: NextRequest) {
|
|
12
12
|
const pathname = request.nextUrl.pathname
|
|
13
13
|
|
|
14
14
|
if (isInfrastructurePath(pathname)) {
|
|
@@ -30,6 +30,15 @@ export function proxy(request: NextRequest) {
|
|
|
30
30
|
return response
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
const seoRedirect = (request.method === "GET" || request.method === "HEAD")
|
|
34
|
+
? await resolveSeoRedirect(request)
|
|
35
|
+
: null
|
|
36
|
+
if (seoRedirect) {
|
|
37
|
+
const response = NextResponse.redirect(seoRedirect.target, seoRedirect.statusCode)
|
|
38
|
+
response.cookies.set(LOCALE_COOKIE, locale, cookieOptions())
|
|
39
|
+
return response
|
|
40
|
+
}
|
|
41
|
+
|
|
33
42
|
const internalPath = internalRewrite(pathname, locale)
|
|
34
43
|
const requestHeaders = new Headers(request.headers)
|
|
35
44
|
requestHeaders.set(LOCALE_HEADER, locale)
|
|
@@ -44,6 +53,49 @@ export function proxy(request: NextRequest) {
|
|
|
44
53
|
return response
|
|
45
54
|
}
|
|
46
55
|
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Resolve Core-managed 301/308 redirects before rewriting localized storefront
|
|
59
|
+
* routes. The SEO module owns redirect targets; the storefront owns HTTP redirects.
|
|
60
|
+
* Fail open if the backend is unavailable so normal storefront navigation keeps working.
|
|
61
|
+
*/
|
|
62
|
+
async function resolveSeoRedirect(request: NextRequest): Promise<{
|
|
63
|
+
target: URL
|
|
64
|
+
statusCode: 301 | 308
|
|
65
|
+
} | null> {
|
|
66
|
+
try {
|
|
67
|
+
const backend = process.env.MEDUSA_BACKEND_URL ||
|
|
68
|
+
process.env.NEXT_PUBLIC_MEDUSA_BACKEND_URL ||
|
|
69
|
+
"http://localhost:9000"
|
|
70
|
+
const endpoint = new URL("/seo/redirect", backend)
|
|
71
|
+
endpoint.searchParams.set("path", request.nextUrl.pathname)
|
|
72
|
+
endpoint.searchParams.set("query", request.nextUrl.searchParams.toString())
|
|
73
|
+
|
|
74
|
+
// Next.js Proxy does not honor fetch revalidate/cache options.
|
|
75
|
+
// Bound lookup time so a slow Core backend cannot stall every storefront page.
|
|
76
|
+
const response = await fetch(endpoint, {
|
|
77
|
+
headers: { accept: "application/json" },
|
|
78
|
+
signal: AbortSignal.timeout(1500),
|
|
79
|
+
})
|
|
80
|
+
if (!response.ok) return null
|
|
81
|
+
|
|
82
|
+
const result = await response.json() as {
|
|
83
|
+
match?: boolean
|
|
84
|
+
target?: string
|
|
85
|
+
statusCode?: number
|
|
86
|
+
}
|
|
87
|
+
if (!result.match || typeof result.target !== "string") return null
|
|
88
|
+
if (result.statusCode !== 301 && result.statusCode !== 308) return null
|
|
89
|
+
|
|
90
|
+
const target = new URL(result.target, request.nextUrl.origin)
|
|
91
|
+
if (target.protocol !== "http:" && target.protocol !== "https:") return null
|
|
92
|
+
if (target.toString() === request.nextUrl.toString()) return null
|
|
93
|
+
return { target, statusCode: result.statusCode }
|
|
94
|
+
} catch {
|
|
95
|
+
return null
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
47
99
|
export const config = {
|
|
48
100
|
matcher: ["/((?!_next/static|_next/image|favicon.ico).*)"],
|
|
49
101
|
}
|
|
@@ -148,5 +200,7 @@ function cookieOptions() {
|
|
|
148
200
|
}
|
|
149
201
|
|
|
150
202
|
function isInfrastructurePath(pathname: string) {
|
|
151
|
-
return pathname === "/robots.txt" || pathname === "/sitemap.xml" ||
|
|
203
|
+
return pathname === "/robots.txt" || pathname === "/sitemap.xml" ||
|
|
204
|
+
pathname.startsWith("/sitemap.xml/") || pathname.startsWith("/api/") ||
|
|
205
|
+
pathname.startsWith("/static/") || /\.[a-z0-9]{2,8}$/i.test(pathname)
|
|
152
206
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import assert from "node:assert/strict"
|
|
2
2
|
import test from "node:test"
|
|
3
|
+
import { readFileSync } from "node:fs"
|
|
3
4
|
import { normalizeCarrierPickupPoint, carrierPointToShippingData } from "../src/components/carrier-pickup-adapter.ts"
|
|
4
5
|
|
|
5
6
|
test("FOXPOST 2in1 point preserves operator and place ID", () => {
|
|
@@ -67,3 +68,18 @@ test("invalid or incomplete widget selection is rejected", () => {
|
|
|
67
68
|
assert.equal(normalizeCarrierPickupPoint("gls", { id: "X", name: "Incomplete" }), null)
|
|
68
69
|
assert.equal(normalizeCarrierPickupPoint("packeta", null), null)
|
|
69
70
|
})
|
|
71
|
+
|
|
72
|
+
test("official GLS widget point avoids a second full-feed lookup before Core shipping save", () => {
|
|
73
|
+
const flow = readFileSync(new URL("../src/components/checkout-flow.tsx", import.meta.url), "utf8")
|
|
74
|
+
const start = flow.indexOf("const verifyCarrierPickupPoint =")
|
|
75
|
+
const end = flow.indexOf("const saveShipping =", start)
|
|
76
|
+
assert.ok(start >= 0 && end > start)
|
|
77
|
+
const verify = flow.slice(start, end)
|
|
78
|
+
assert.match(verify, /if \(kind === "gls"\) return picked/)
|
|
79
|
+
assert.doesNotMatch(verify, /api\.glsDeliveryPoints\(/)
|
|
80
|
+
assert.match(verify, /api\.foxpostLockers\(\)/)
|
|
81
|
+
assert.match(verify, /api\.mplDeliveryPlaces\(/)
|
|
82
|
+
assert.match(flow, /const verifiedPoint = await verifyCarrierPickupPoint\(kind, selectedPickupPoint\)/)
|
|
83
|
+
assert.match(flow, /const data = shippingData\(kind, verifiedPoint, locale\)/)
|
|
84
|
+
assert.match(flow, /api\.addShippingMethod\(cartId, optionId, data\)/)
|
|
85
|
+
})
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import assert from "node:assert/strict"
|
|
2
|
+
import { readFileSync } from "node:fs"
|
|
3
|
+
import { test } from "node:test"
|
|
4
|
+
import { parseSitemapPage, sitemapSourcePath, serializeJsonLd } from "../src/lib/core/seo-output.ts"
|
|
5
|
+
|
|
6
|
+
test("sitemap shards are forwarded unchanged to the Core source endpoint", () => {
|
|
7
|
+
assert.equal(parseSitemapPage("https://example.hu/sitemap.xml"), null)
|
|
8
|
+
assert.equal(parseSitemapPage("https://example.hu/sitemap.xml?page=2"), 2)
|
|
9
|
+
assert.equal(sitemapSourcePath("/seo/sitemap.xml", 2), "/seo/sitemap.xml?page=2")
|
|
10
|
+
assert.equal(sitemapSourcePath("/seo/sitemap.xml", null), "/seo/sitemap.xml")
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
test("invalid sitemap pagination is rejected instead of returning an unrelated shard", () => {
|
|
14
|
+
for (const page of ["0", "-1", "x", "1.5", "01", "9007199254740993"]) {
|
|
15
|
+
assert.throws(() => parseSitemapPage(`https://example.hu/sitemap.xml?page=${page}`))
|
|
16
|
+
}
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
test("JSON-LD cannot be terminated by user-supplied markup", () => {
|
|
20
|
+
const output = serializeJsonLd({ name: "</script><script>alert(1)</script>" })
|
|
21
|
+
assert.ok(!output.includes("</script>"))
|
|
22
|
+
assert.ok(output.includes("u003c"))
|
|
23
|
+
assert.deepEqual(JSON.parse(output), { name: "</script><script>alert(1)</script>" })
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
test("Core redirects are executed before internal route rewrites", () => {
|
|
27
|
+
const proxy = readFileSync(new URL("../src/proxy.ts", import.meta.url), "utf8")
|
|
28
|
+
assert.match(proxy, /await resolveSeoRedirect\(request\)/)
|
|
29
|
+
assert.match(proxy, /NextResponse\.redirect\(seoRedirect\.target, seoRedirect\.statusCode\)/)
|
|
30
|
+
assert.ok(proxy.indexOf("await resolveSeoRedirect(request)") < proxy.indexOf("const internalPath = internalRewrite("))
|
|
31
|
+
assert.match(proxy, /endpoint\.searchParams\.set\("query"/)
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
test("technical storefront routes return noindex and public list pages define canonical metadata", () => {
|
|
35
|
+
const read = (path) => readFileSync(new URL(`../src/app/${path}`, import.meta.url), "utf8")
|
|
36
|
+
for (const route of ["account", "cart", "checkout", "cart-recovery", "reset-password", "newsletter"]) {
|
|
37
|
+
assert.match(read(`${route}/layout.tsx`), /index: false, follow: false/)
|
|
38
|
+
}
|
|
39
|
+
for (const route of ["page.tsx", "blog/page.tsx", "knowledge-base/page.tsx", "[countryCode]/products/page.tsx"]) {
|
|
40
|
+
assert.match(read(route), /metadataForPublicPage/)
|
|
41
|
+
}
|
|
42
|
+
})
|