Merge branch 'original-main'

This commit is contained in:
Björn Meyer 2023-08-16 10:30:31 +02:00
commit 44eb9a588a
4 changed files with 17 additions and 13 deletions

View File

@ -1,4 +1,5 @@
import Navbar from 'components/layout/navbar';
import { ensureStartsWith } from 'lib/utils';
import { Inter } from 'next/font/google';
import { ReactNode, Suspense } from 'react';
import './globals.css';
@ -7,6 +8,8 @@ const { TWITTER_CREATOR, TWITTER_SITE, SITE_NAME } = process.env;
const baseUrl = process.env.NEXT_PUBLIC_VERCEL_URL
? `https://${process.env.NEXT_PUBLIC_VERCEL_URL}`
: 'http://localhost:3000';
const twitterCreator = TWITTER_CREATOR ? ensureStartsWith(TWITTER_CREATOR, '@') : undefined;
const twitterSite = TWITTER_SITE ? ensureStartsWith(TWITTER_SITE, 'https://') : undefined;
export const metadata = {
metadataBase: new URL(baseUrl),
@ -18,12 +21,12 @@ export const metadata = {
follow: true,
index: true
},
...(TWITTER_CREATOR &&
TWITTER_SITE && {
...(twitterCreator &&
twitterSite && {
twitter: {
card: 'summary_large_image',
creator: TWITTER_CREATOR,
site: TWITTER_SITE
creator: twitterCreator,
site: twitterSite
}
})
};

View File

@ -18,11 +18,7 @@ export default async function Navbar() {
</div>
<div className="flex w-full items-center">
<div className="flex w-full md:w-4/6">
<Link
href="/"
aria-label="Go back home"
className="mr-2 flex w-full items-center justify-center md:w-auto lg:mr-6"
>
<Link href="/" className="mr-2 flex w-full items-center justify-center md:w-auto lg:mr-6">
<LogoSquare />
</Link>
{menu.length ? (

View File

@ -1,3 +1,5 @@
import { ensureStartsWith } from 'lib/utils';
export function getAccessToken(): string {
return `${process.env.SHOPWARE_ACCESS_TOKEN}`;
}
@ -6,10 +8,10 @@ export function getStoreDomainWithApiType(): string {
return getStoreDomain() + '/' + getApiType();
}
export function getStoreDomain(protocol: boolean = true): string {
return protocol
? `https://${process.env.SHOPWARE_STORE_DOMAIN!}`
: `${process.env.SHOPWARE_STORE_DOMAIN!}`;
export function getStoreDomain(): string {
return process.env.SHOPWARE_STORE_DOMAIN
? ensureStartsWith(process.env.SHOPWARE_STORE_DOMAIN, 'https://')
: '';
}
export function getApiType(): 'store-api' | 'admin-api' {

View File

@ -6,3 +6,6 @@ export const createUrl = (pathname: string, params: URLSearchParams | ReadonlyUR
return `${pathname}${queryString}`;
};
export const ensureStartsWith = (stringToCheck: string, startsWith: string) =>
stringToCheck.startsWith(startsWith) ? stringToCheck : `${startsWith}${stringToCheck}`;