mirror of
https://github.com/vercel/commerce.git
synced 2025-05-14 21:47:51 +00:00
Merge branch 'original-main'
This commit is contained in:
commit
44eb9a588a
@ -1,4 +1,5 @@
|
|||||||
import Navbar from 'components/layout/navbar';
|
import Navbar from 'components/layout/navbar';
|
||||||
|
import { ensureStartsWith } from 'lib/utils';
|
||||||
import { Inter } from 'next/font/google';
|
import { Inter } from 'next/font/google';
|
||||||
import { ReactNode, Suspense } from 'react';
|
import { ReactNode, Suspense } from 'react';
|
||||||
import './globals.css';
|
import './globals.css';
|
||||||
@ -7,6 +8,8 @@ const { TWITTER_CREATOR, TWITTER_SITE, SITE_NAME } = process.env;
|
|||||||
const baseUrl = process.env.NEXT_PUBLIC_VERCEL_URL
|
const baseUrl = process.env.NEXT_PUBLIC_VERCEL_URL
|
||||||
? `https://${process.env.NEXT_PUBLIC_VERCEL_URL}`
|
? `https://${process.env.NEXT_PUBLIC_VERCEL_URL}`
|
||||||
: 'http://localhost:3000';
|
: 'http://localhost:3000';
|
||||||
|
const twitterCreator = TWITTER_CREATOR ? ensureStartsWith(TWITTER_CREATOR, '@') : undefined;
|
||||||
|
const twitterSite = TWITTER_SITE ? ensureStartsWith(TWITTER_SITE, 'https://') : undefined;
|
||||||
|
|
||||||
export const metadata = {
|
export const metadata = {
|
||||||
metadataBase: new URL(baseUrl),
|
metadataBase: new URL(baseUrl),
|
||||||
@ -18,12 +21,12 @@ export const metadata = {
|
|||||||
follow: true,
|
follow: true,
|
||||||
index: true
|
index: true
|
||||||
},
|
},
|
||||||
...(TWITTER_CREATOR &&
|
...(twitterCreator &&
|
||||||
TWITTER_SITE && {
|
twitterSite && {
|
||||||
twitter: {
|
twitter: {
|
||||||
card: 'summary_large_image',
|
card: 'summary_large_image',
|
||||||
creator: TWITTER_CREATOR,
|
creator: twitterCreator,
|
||||||
site: TWITTER_SITE
|
site: twitterSite
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
|
@ -18,11 +18,7 @@ export default async function Navbar() {
|
|||||||
</div>
|
</div>
|
||||||
<div className="flex w-full items-center">
|
<div className="flex w-full items-center">
|
||||||
<div className="flex w-full md:w-4/6">
|
<div className="flex w-full md:w-4/6">
|
||||||
<Link
|
<Link href="/" className="mr-2 flex w-full items-center justify-center md:w-auto lg:mr-6">
|
||||||
href="/"
|
|
||||||
aria-label="Go back home"
|
|
||||||
className="mr-2 flex w-full items-center justify-center md:w-auto lg:mr-6"
|
|
||||||
>
|
|
||||||
<LogoSquare />
|
<LogoSquare />
|
||||||
</Link>
|
</Link>
|
||||||
{menu.length ? (
|
{menu.length ? (
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
import { ensureStartsWith } from 'lib/utils';
|
||||||
|
|
||||||
export function getAccessToken(): string {
|
export function getAccessToken(): string {
|
||||||
return `${process.env.SHOPWARE_ACCESS_TOKEN}`;
|
return `${process.env.SHOPWARE_ACCESS_TOKEN}`;
|
||||||
}
|
}
|
||||||
@ -6,10 +8,10 @@ export function getStoreDomainWithApiType(): string {
|
|||||||
return getStoreDomain() + '/' + getApiType();
|
return getStoreDomain() + '/' + getApiType();
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getStoreDomain(protocol: boolean = true): string {
|
export function getStoreDomain(): string {
|
||||||
return protocol
|
return process.env.SHOPWARE_STORE_DOMAIN
|
||||||
? `https://${process.env.SHOPWARE_STORE_DOMAIN!}`
|
? ensureStartsWith(process.env.SHOPWARE_STORE_DOMAIN, 'https://')
|
||||||
: `${process.env.SHOPWARE_STORE_DOMAIN!}`;
|
: '';
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getApiType(): 'store-api' | 'admin-api' {
|
export function getApiType(): 'store-api' | 'admin-api' {
|
||||||
|
@ -6,3 +6,6 @@ export const createUrl = (pathname: string, params: URLSearchParams | ReadonlyUR
|
|||||||
|
|
||||||
return `${pathname}${queryString}`;
|
return `${pathname}${queryString}`;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const ensureStartsWith = (stringToCheck: string, startsWith: string) =>
|
||||||
|
stringToCheck.startsWith(startsWith) ? stringToCheck : `${startsWith}${stringToCheck}`;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user