The complete open source platform to run your entire marketplace. Storefront, vendor panel, admin console, and integrations in one enterprise-grade platform you own.
TypeScript b2b-marketplacecomposable-commerceecommerceenterpriseheadless-commercemarketplacemedusamedusajsmulti-vendortypescript
import { BannerSection } from '@/components/sections/BannerSection/BannerSection';
import { BlogSection } from '@/components/sections/BlogSection/BlogSection';
import { Hero } from '@/components/sections/Hero/Hero';
import { HomeCategories } from '@/components/sections/HomeCategories/HomeCategories';
import { HomeProductSection } from '@/components/sections/HomeProductSection/HomeProductSection';
import { ShopByStyleSection } from '@/components/sections/ShopByStyle/ShopByStyleSection';
import type { Metadata } from "next"
import { getBaseUrl } from "@/lib/helpers/base-url"
import Script from "next/script"
import { listRegions } from "@/lib/data/regions"
import {
buildHreflangAlternates,
getStorefrontLocales,
toHreflang,
} from "@/lib/helpers/hreflang"
export async function generateMetadata({
params,
}: {
params: Promise<{ locale: string }>
}): Promise<Metadata> {
const { locale } = await params
const baseUrl = getBaseUrl()
let locales: string[] = []
try {
locales = getStorefrontLocales(await listRegions())
} catch {
locales = [locale]
}
const { canonical, languages } = buildHreflangAlternates({
baseUrl,
path: "",
locale,
locales,
})
const title = "Home"
const description =
"Welcome to Mercur B2C Demo! Create a modern marketplace that you own and customize in every aspect with high-performance, fully customizable storefront."
const ogImage = "/B2C_Storefront_Open_Graph.png"
return {
title,
description,
robots: {
index: true,
follow: true,
googleBot: {
index: true,
follow: true,
"max-image-preview": "large",
"max-video-preview": -1,
"max-snippet": -1,
},
},
alternates: {
canonical,
languages,
},
openGraph: {
title: `${title} | ${
process.env.NEXT_PUBLIC_SITE_NAME ||
"Mercur B2C Demo - Marketplace Storefront"
}`,
description,
url: canonical,
siteName:
process.env.NEXT_PUBLIC_SITE_NAME ||
"Mercur B2C Demo - Marketplace Storefront",
type: "website",
images: [
{
url: ogImage.startsWith("http") ? ogImage : `${baseUrl}${ogImage}`,
width: 1200,
height: 630,
alt:
process.env.NEXT_PUBLIC_SITE_NAME ||
"Mercur B2C Demo - Marketplace Storefront",
},
],
},
twitter: {
card: "summary_large_image",
title,
description,
images: [ogImage.startsWith("http") ? ogImage : `${baseUrl}${ogImage}`],
},
}
}
export default async function Home({
params,
}: {
params: Promise<{ locale: string }>
}) {
const { locale } = await params
const baseUrl = getBaseUrl()
const siteName =
process.env.NEXT_PUBLIC_SITE_NAME ||
"Mercur B2C Demo - Marketplace Storefront"
return (
<main className="flex flex-col gap-8 row-start-2 items-center sm:items-start text-primary">
<link
rel="preload"
as="image"
href="/images/hero/Image.jpg"
imageSrcSet="/images/hero/Image.jpg 700w"
imageSizes="(min-width: 1024px) 50vw, 100vw"
/>
<Script
id="ld-org"
type="application/ld+json"
dangerouslySetInnerHTML={{
__html: JSON.stringify({
"@context": "https://schema.org",
"@type": "Organization",
name: siteName,
url: `${baseUrl}/${locale}`,
logo: `${baseUrl}/favicon.ico`,
}),
}}
/>
<Script
id="ld-website"
type="application/ld+json"
dangerouslySetInnerHTML={{
__html: JSON.stringify({
"@context": "https://schema.org",
"@type": "WebSite",
name: siteName,
url: `${baseUrl}/${locale}`,
inLanguage: toHreflang(locale),
}),
}}
/>
<Hero
image="/images/hero/Image.jpg"
heading="Snag your style in a flash"
paragraph="Buy, sell, and discover pre-loved gems from the trendiest brands."
buttons={[
{ label: "Buy now", path: "/categories" },
{
label: "Sell now",
path:
process.env.NEXT_PUBLIC_VENDOR_URL ||
"https://vendor.mercurjs.com",
},
]}
/>
<div className="px-4 lg:px-8 w-full">
<HomeProductSection heading="trending listings" locale={locale} home />
</div>
<div className="px-4 lg:px-8 w-full">
<HomeCategories heading="SHOP BY CATEGORY" />
</div>
<BannerSection />
<ShopByStyleSection />
<BlogSection />
</main>
)
}