From 206172099425a7bbec2c142baf18e256939405fc Mon Sep 17 00:00:00 2001 From: Sam Becker Date: Fri, 8 Sep 2023 11:29:45 -0500 Subject: [PATCH] Make domain configuration optional --- README.md | 2 +- src/app/(isr)/template-url/route.tsx | 1 - src/components/Nav.tsx | 4 ++-- src/site/SiteChecklistClient.tsx | 3 ++- src/site/SiteChecklistRow.tsx | 14 +++++++++++--- src/site/config.ts | 7 ++++--- src/site/routes.ts | 4 ++-- 7 files changed, 22 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 49682174..13461013 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ _Database schema changes are expected._ ![App Preview](app-preview.png) -[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?demo-title=Photo+Blog&demo-description=Store+photos+with+original+camera+data&demo-url=https%3A%2F%2Fphotos.sambecker.com&demo-image=https%3A%2F%2Fphotos.sambecker.com%2Ftemplate-image-tight&project-name=Photo+Blog&repository-name=photo-blog&repository-url=https%3A%2F%2Fgithub.com%2Fsambecker%2Fphoto-blog&from=templates&skippable-integrations=1&env-description=Configure+your+photo+blog+meta&env-link=BLANK&env=NEXT_PUBLIC_SITE_TITLE%2CNEXT_PUBLIC_SITE_DOMAIN&teamCreateStatus=hidden&stores=%5B%7B%22type%22%3A%22postgres%22%7D%2C%7B%22type%22%3A%22blob%22%7D%5D) +[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?demo-title=Photo+Blog&demo-description=Store+photos+with+original+camera+data&demo-url=https%3A%2F%2Fphotos.sambecker.com&demo-image=https%3A%2F%2Fphotos.sambecker.com%2Ftemplate-image-tight&project-name=Photo+Blog&repository-name=photo-blog&repository-url=https%3A%2F%2Fgithub.com%2Fsambecker%2Fphoto-blog&from=templates&skippable-integrations=1&env-description=Configure+your+photo+blog+meta&env-link=BLANK&env=NEXT_PUBLIC_SITE_TITLE&teamCreateStatus=hidden&stores=%5B%7B%22type%22%3A%22postgres%22%7D%2C%7B%22type%22%3A%22blob%22%7D%5D) ### 1. Deploy to Vercel diff --git a/src/app/(isr)/template-url/route.tsx b/src/app/(isr)/template-url/route.tsx index d1df37aa..d0610986 100644 --- a/src/app/(isr)/template-url/route.tsx +++ b/src/app/(isr)/template-url/route.tsx @@ -22,7 +22,6 @@ export function GET() { url.searchParams.set('env-link', 'BLANK'); url.searchParams.set('env', [ 'NEXT_PUBLIC_SITE_TITLE', - 'NEXT_PUBLIC_SITE_DOMAIN', ].join(',')); url.searchParams.set('teamCreateStatus', 'hidden'); url.searchParams.set('stores', JSON.stringify([ diff --git a/src/components/Nav.tsx b/src/components/Nav.tsx index f000cadd..2b7b1ba6 100644 --- a/src/components/Nav.tsx +++ b/src/components/Nav.tsx @@ -4,7 +4,7 @@ import { cc } from '@/utility/css'; import { usePathname } from 'next/navigation'; import Link from 'next/link'; import SiteGrid from './SiteGrid'; -import { SITE_DOMAIN } from '@/site/config'; +import { SITE_DOMAIN_OR_TITLE } from '@/site/config'; import ViewSwitcher, { SwitcherSelection } from '@/photo/ViewSwitcher'; export default function Nav({ showTextLinks }: { showTextLinks?: boolean }) { @@ -52,7 +52,7 @@ export default function Nav({ showTextLinks }: { showTextLinks?: boolean }) { }
- {renderLink(SITE_DOMAIN, '/')} + {renderLink(SITE_DOMAIN_OR_TITLE, '/')}
} diff --git a/src/site/SiteChecklistClient.tsx b/src/site/SiteChecklistClient.tsx index e997f681..279f4744 100644 --- a/src/site/SiteChecklistClient.tsx +++ b/src/site/SiteChecklistClient.tsx @@ -95,9 +95,10 @@ export default function SiteChecklistClient({ {renderEnvVars(['NEXT_PUBLIC_SITE_TITLE'])} Store in environment variable: {renderEnvVars(['NEXT_PUBLIC_SITE_DOMAIN'])} diff --git a/src/site/SiteChecklistRow.tsx b/src/site/SiteChecklistRow.tsx index d6aed8b0..e17c7cb9 100644 --- a/src/site/SiteChecklistRow.tsx +++ b/src/site/SiteChecklistRow.tsx @@ -6,11 +6,13 @@ export default function SiteChecklistRow({ title, status, isPending, + optional, children, }: { title: string status: boolean isPending: boolean + optional?: boolean children: ReactNode }) { return ( @@ -25,12 +27,18 @@ export default function SiteChecklistRow({ :
- {status ? '✅' : '❌'} + {status + ? '✅' + : optional ? '—' : '❌'}
}
-
{title}
-
{children}
+
+ {title}{optional && ' (optional)'} +
+
+ {children} +
); diff --git a/src/site/config.ts b/src/site/config.ts index 76772b2b..a9858d0f 100644 --- a/src/site/config.ts +++ b/src/site/config.ts @@ -1,9 +1,10 @@ export const SITE_TITLE = process.env.NEXT_PUBLIC_SITE_TITLE || 'Photo Blog'; -export const SITE_DOMAIN = process.env.NEXT_PUBLIC_SITE_DOMAIN - || process.env.NEXT_PUBLIC_VERCEL_URL - || SITE_TITLE; +const SITE_DOMAIN = process.env.NEXT_PUBLIC_SITE_DOMAIN + || process.env.NEXT_PUBLIC_VERCEL_URL; + +export const SITE_DOMAIN_OR_TITLE = SITE_DOMAIN || SITE_TITLE; export const SITE_DESCRIPTION = process.env.NEXT_PUBLIC_SITE_DESCRIPTION || SITE_DOMAIN; diff --git a/src/site/routes.ts b/src/site/routes.ts index 255cfd6b..19a66dcb 100644 --- a/src/site/routes.ts +++ b/src/site/routes.ts @@ -1,5 +1,5 @@ import { Photo } from '@/photo'; -import { SITE_DOMAIN } from './config'; +import { BASE_URL } from './config'; export const ROUTE_ADMIN_UPLOAD = '/admin/uploads'; @@ -11,7 +11,7 @@ export const routeForPhoto = (photo: Photo, share?: boolean) => : `/photos/${photo.idShort}`; export const absoluteRouteForPhoto = (photo: Photo) => - `https://${SITE_DOMAIN}${routeForPhoto(photo)}`; + `${BASE_URL}${routeForPhoto(photo)}`; export const isRoutePhoto = (pathname = '') => /^\/photos\/[^/]+\/?$/.test(pathname);