From 1488becc9ca910351af24ecbed21f144e9f106d7 Mon Sep 17 00:00:00 2001 From: Sam Becker Date: Sat, 29 Jun 2024 22:33:26 -0500 Subject: [PATCH] Rename grid homepage environment variable --- README.md | 2 +- src/app/page.tsx | 8 ++++---- src/site/Nav.tsx | 4 ++-- src/site/SiteChecklistClient.tsx | 4 ++-- src/site/ViewSwitcher.tsx | 10 +++++----- src/site/config.ts | 6 +++--- 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 10074926..c9dd7b98 100644 --- a/README.md +++ b/README.md @@ -99,7 +99,7 @@ _⚠️ READ BEFORE PROCEEDING_ Application behavior can be changed by configuring the following environment variables: - `NEXT_PUBLIC_PRO_MODE = 1` enables higher quality image storage (results in increased storage usage) -- `NEXT_PUBLIC_SHOW_GRID_FIRST = 1` shows grid layout on homepage +- `NEXT_PUBLIC_GRID_HOMEPAGE = 1` shows grid layout on homepage - `NEXT_PUBLIC_STATICALLY_OPTIMIZE_PAGES = 1` enables static optimization for pages, i.e., renders pages at build time (results in increased project usage)—⚠️ _Experimental_ - `NEXT_PUBLIC_STATICALLY_OPTIMIZE_OG_IMAGES = 1` enables static optimization for OG images, i.e., renders images at build time (results in increased project usage)—⚠️ _Experimental_ - `NEXT_PUBLIC_MATTE_PHOTOS = 1` constrains the size of each photo, and enables a surrounding border (potentially useful for photos with tall aspect ratios) diff --git a/src/app/page.tsx b/src/app/page.tsx index 9a3b83e1..fb6a9f22 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -7,7 +7,7 @@ import PhotosEmptyState from '@/photo/PhotosEmptyState'; import { Metadata } from 'next/types'; import { cache } from 'react'; import { getPhotos, getPhotosMeta } from '@/photo/db/query'; -import { SHOW_GRID_FIRST } from '@/site/config'; +import { GRID_HOMEPAGE_ENABLED } from '@/site/config'; import { getPhotoSidebarData } from '@/photo/data'; import PhotoGridPage from '@/photo/PhotoGridPage'; import PhotoFeedPage from '@/photo/PhotoFeedPage'; @@ -16,7 +16,7 @@ export const dynamic = 'force-static'; export const maxDuration = 60; const getPhotosCached = cache(() => getPhotos({ - limit: SHOW_GRID_FIRST + limit: GRID_HOMEPAGE_ENABLED ? INFINITE_SCROLL_GRID_INITIAL : INFINITE_SCROLL_FEED_INITIAL, })); @@ -40,14 +40,14 @@ export default async function HomePage() { getPhotosMeta() .then(({ count }) => count) .catch(() => 0), - ...(SHOW_GRID_FIRST + ...(GRID_HOMEPAGE_ENABLED ? getPhotoSidebarData() : [[], [], []]), ]); return ( photos.length > 0 - ? SHOW_GRID_FIRST + ? GRID_HOMEPAGE_ENABLED ? diff --git a/src/site/Nav.tsx b/src/site/Nav.tsx index 16e99ca9..4245ec66 100644 --- a/src/site/Nav.tsx +++ b/src/site/Nav.tsx @@ -15,7 +15,7 @@ import { } from '@/site/paths'; import AnimateItems from '../components/AnimateItems'; import { useAppState } from '@/state/AppState'; -import { SHOW_GRID_FIRST } from './config'; +import { GRID_HOMEPAGE_ENABLED } from './config'; export default function Nav({ siteDomainOrTitle, @@ -38,7 +38,7 @@ export default function Nav({ const switcherSelectionForPath = (): SwitcherSelection | undefined => { if (pathname === PATH_ROOT) { - return SHOW_GRID_FIRST ? 'grid' : 'feed'; + return GRID_HOMEPAGE_ENABLED ? 'grid' : 'feed'; } else if (isPathGrid(pathname)) { return 'grid'; } else if (isPathFeed(pathname)) { diff --git a/src/site/SiteChecklistClient.tsx b/src/site/SiteChecklistClient.tsx index 8fe45620..72f5a631 100644 --- a/src/site/SiteChecklistClient.tsx +++ b/src/site/SiteChecklistClient.tsx @@ -49,7 +49,7 @@ export default function SiteChecklistClient({ showFilmSimulations, showExifInfo, isProModeEnabled, - isGridFirst, + isGridHomepageEnabled: isGridFirst, isStaticallyOptimized, arePagesStaticallyOptimized, areOGImagesStaticallyOptimized, @@ -432,7 +432,7 @@ export default function SiteChecklistClient({ > Set environment variable to {'"1"'} to show grid layout on homepage: - {renderEnvVars(['NEXT_PUBLIC_SHOW_GRID_FIRST'])} + {renderEnvVars(['NEXT_PUBLIC_GRID_HOMEPAGE'])} } - href={SHOW_GRID_FIRST ? PATH_FEED : PATH_ROOT} + href={GRID_HOMEPAGE_ENABLED ? PATH_FEED : PATH_ROOT} active={currentSelection === 'feed'} noPadding />; @@ -35,7 +35,7 @@ export default function ViewSwitcher({ const renderItemGrid = () => } - href={SHOW_GRID_FIRST ? PATH_ROOT : PATH_GRID} + href={GRID_HOMEPAGE_ENABLED ? PATH_ROOT : PATH_GRID} active={currentSelection === 'grid'} noPadding />; @@ -43,8 +43,8 @@ export default function ViewSwitcher({ return (
- {SHOW_GRID_FIRST ? renderItemGrid() : renderItemFeed()} - {SHOW_GRID_FIRST ? renderItemFeed() : renderItemGrid()} + {GRID_HOMEPAGE_ENABLED ? renderItemGrid() : renderItemFeed()} + {GRID_HOMEPAGE_ENABLED ? renderItemFeed() : renderItemGrid()} {showAdmin && } diff --git a/src/site/config.ts b/src/site/config.ts index 720a8502..632de200 100644 --- a/src/site/config.ts +++ b/src/site/config.ts @@ -116,8 +116,8 @@ export const CURRENT_STORAGE: StorageType = export const PRO_MODE_ENABLED = process.env.NEXT_PUBLIC_PRO_MODE === '1'; -export const SHOW_GRID_FIRST = - process.env.NEXT_PUBLIC_SHOW_GRID_FIRST === '1'; +export const GRID_HOMEPAGE_ENABLED = + process.env.NEXT_PUBLIC_GRID_HOMEPAGE === '1'; export const STATICALLY_OPTIMIZED_PAGES = process.env.NEXT_PUBLIC_STATICALLY_OPTIMIZE_PAGES === '1'; export const STATICALLY_OPTIMIZED_OG_IMAGES = @@ -185,7 +185,7 @@ export const CONFIG_CHECKLIST_STATUS = { showFilmSimulations: SHOW_FILM_SIMULATIONS, showExifInfo: SHOW_EXIF_DATA, isProModeEnabled: PRO_MODE_ENABLED, - isGridFirst: SHOW_GRID_FIRST, + isGridHomepageEnabled: GRID_HOMEPAGE_ENABLED, isStaticallyOptimized: ( STATICALLY_OPTIMIZED_PAGES || STATICALLY_OPTIMIZED_OG_IMAGES