diff --git a/.env.example b/.env.example index bd952c531..6a0941ecf 100644 --- a/.env.example +++ b/.env.example @@ -1,3 +1,6 @@ +TWITTER_CREATOR="@vercel" +TWITTER_SITE="https://nextjs.org/commerce" +SITE_NAME="Next.js Commerce" SHOPIFY_STOREFRONT_ACCESS_TOKEN= SHOPIFY_STORE_DOMAIN= SHOPIFY_REVALIDATION_TOKEN= diff --git a/app/api/og/route.tsx b/app/api/og/route.tsx index 8ffa90866..e1d70e35f 100644 --- a/app/api/og/route.tsx +++ b/app/api/og/route.tsx @@ -1,5 +1,4 @@ import { ImageResponse } from '@vercel/og'; -import { SITE_NAME } from 'lib/constants'; import { NextRequest } from 'next/server'; export const runtime = 'edge'; @@ -18,7 +17,9 @@ export async function GET(req: NextRequest): Promise { const { searchParams } = new URL(req.url); - const title = searchParams.has('title') ? searchParams.get('title')?.slice(0, 100) : SITE_NAME; + const title = searchParams.has('title') + ? searchParams.get('title')?.slice(0, 100) + : process.env.SITE_NAME; return new ImageResponse( ( diff --git a/app/layout.tsx b/app/layout.tsx index 489f48b21..f1e4769af 100644 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -1,9 +1,9 @@ +import Navbar from 'components/layout/navbar'; import { Inter } from 'next/font/google'; import { ReactNode, Suspense } from 'react'; import './globals.css'; -import Navbar from 'components/layout/navbar'; -import { SITE_CREATOR, SITE_CREATOR_URL, SITE_NAME } from 'lib/constants'; +const { TWITTER_CREATOR, TWITTER_SITE, SITE_NAME } = process.env; export const metadata = { title: { @@ -14,11 +14,14 @@ export const metadata = { follow: true, index: true }, - twitter: { - card: 'summary_large_image', - creator: SITE_CREATOR, - site: SITE_CREATOR_URL - } + ...(TWITTER_CREATOR && + TWITTER_SITE && { + twitter: { + card: 'summary_large_image', + creator: TWITTER_CREATOR, + site: TWITTER_SITE + } + }) }; const inter = Inter({ diff --git a/app/page.tsx b/app/page.tsx index 4580e53c2..d398f0fbb 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -1,7 +1,6 @@ import { Carousel } from 'components/carousel'; import { ThreeItemGrid } from 'components/grid/three-items'; import Footer from 'components/layout/footer'; -import { SITE_NAME } from 'lib/constants'; import { Suspense } from 'react'; export const runtime = 'edge'; @@ -11,7 +10,7 @@ export const metadata = { openGraph: { images: [ { - url: `/api/og?title=${encodeURIComponent(SITE_NAME)}`, + url: `/api/og?title=${encodeURIComponent(process.env.SITE_NAME)}`, width: 1200, height: 630 } diff --git a/components/icons/logo.tsx b/components/icons/logo.tsx index 951d9baa2..cdcfc8fe2 100644 --- a/components/icons/logo.tsx +++ b/components/icons/logo.tsx @@ -1,10 +1,8 @@ -import { SITE_NAME } from 'lib/constants'; - export default function LogoIcon({ className }: { className?: string }) { return ( 2023 ? `-${currentYear}` : ''); const menu = await getMenu('next-js-frontend-footer-menu'); return ( @@ -45,7 +48,9 @@ export default async function Footer() {
-

© 2023 {SITE_NAME}. All rights reserved.

+

+ © {copyrightDate} {SITE_NAME}. All rights reserved. +

Created by