Enable configuration-driven static optimization
This commit is contained in:
parent
07fc0f0c24
commit
f5a5b4aef6
@ -62,7 +62,8 @@ Installation
|
|||||||
|
|
||||||
### 6. Optional configuration
|
### 6. Optional configuration
|
||||||
|
|
||||||
- `NEXT_PUBLIC_PRO_MODE = 1` enables higher quality image storage (will result in increased storage usage)
|
- `NEXT_PUBLIC_PRO_MODE = 1` enables higher quality image storage (results in increased storage usage)
|
||||||
|
- `NEXT_PUBLIC_STATICALLY_OPTIMIZE = 1` enables PPR and static optimization, i.e., building pages ahead of time (results in increased storage usage)—⚠️ _Experimental_
|
||||||
- `NEXT_PUBLIC_BLUR_DISABLED = 1` prevents image blur data being stored and displayed (potentially useful for limiting Postgres usage)
|
- `NEXT_PUBLIC_BLUR_DISABLED = 1` prevents image blur data being stored and displayed (potentially useful for limiting Postgres usage)
|
||||||
- `NEXT_PUBLIC_GEO_PRIVACY = 1` disables collection/display of location-based data
|
- `NEXT_PUBLIC_GEO_PRIVACY = 1` disables collection/display of location-based data
|
||||||
- `NEXT_PUBLIC_IGNORE_PRIORITY_ORDER = 1` prevents `priority_order` field affecting photo order
|
- `NEXT_PUBLIC_IGNORE_PRIORITY_ORDER = 1` prevents `priority_order` field affecting photo order
|
||||||
|
|||||||
@ -35,8 +35,8 @@ const nextConfig = {
|
|||||||
.concat(createRemotePattern(AWS_S3_HOSTNAME)),
|
.concat(createRemotePattern(AWS_S3_HOSTNAME)),
|
||||||
minimumCacheTTL: 31536000,
|
minimumCacheTTL: 31536000,
|
||||||
},
|
},
|
||||||
experimental: {
|
...process.env.NEXT_PUBLIC_STATICALLY_OPTIMIZE === '1' && {
|
||||||
ppr: true,
|
experimental: { ppr: true },
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -14,12 +14,17 @@ import {
|
|||||||
import PhotoDetailPage from '@/photo/PhotoDetailPage';
|
import PhotoDetailPage from '@/photo/PhotoDetailPage';
|
||||||
import { getPhotosNearIdCached } from '@/photo/cache';
|
import { getPhotosNearIdCached } from '@/photo/cache';
|
||||||
import { getPhotoIds } from '@/services/vercel-postgres';
|
import { getPhotoIds } from '@/services/vercel-postgres';
|
||||||
|
import { STATICALLY_OPTIMIZED } from '@/site/config';
|
||||||
|
|
||||||
export async function generateStaticParams() {
|
export async function generateStaticParams() {
|
||||||
const photos = await getPhotoIds({ limit: GENERATE_STATIC_PARAMS_LIMIT });
|
if (STATICALLY_OPTIMIZED) {
|
||||||
return photos.map(photoId => ({
|
const photos = await getPhotoIds({ limit: GENERATE_STATIC_PARAMS_LIMIT });
|
||||||
params: { photoId },
|
return photos.map(photoId => ({
|
||||||
}));
|
params: { photoId },
|
||||||
|
}));
|
||||||
|
} else {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
interface PhotoProps {
|
interface PhotoProps {
|
||||||
|
|||||||
@ -2,12 +2,14 @@ import { clsx } from 'clsx/lite';
|
|||||||
|
|
||||||
export default function Badge({
|
export default function Badge({
|
||||||
children,
|
children,
|
||||||
|
className,
|
||||||
type = 'large',
|
type = 'large',
|
||||||
highContrast,
|
highContrast,
|
||||||
uppercase,
|
uppercase,
|
||||||
interactive,
|
interactive,
|
||||||
}: {
|
}: {
|
||||||
children: React.ReactNode
|
children: React.ReactNode
|
||||||
|
className?: string
|
||||||
type?: 'large' | 'small' | 'text-only'
|
type?: 'large' | 'small' | 'text-only'
|
||||||
highContrast?: boolean
|
highContrast?: boolean
|
||||||
uppercase?: boolean
|
uppercase?: boolean
|
||||||
@ -39,6 +41,7 @@ export default function Badge({
|
|||||||
};
|
};
|
||||||
return (
|
return (
|
||||||
<span className={clsx(
|
<span className={clsx(
|
||||||
|
className,
|
||||||
'leading-none',
|
'leading-none',
|
||||||
stylesForType(),
|
stylesForType(),
|
||||||
uppercase && 'uppercase tracking-wider',
|
uppercase && 'uppercase tracking-wider',
|
||||||
|
|||||||
@ -7,12 +7,14 @@ export default function ChecklistRow({
|
|||||||
status,
|
status,
|
||||||
isPending,
|
isPending,
|
||||||
optional,
|
optional,
|
||||||
|
experimental,
|
||||||
children,
|
children,
|
||||||
}: {
|
}: {
|
||||||
title: string
|
title: string
|
||||||
status: boolean
|
status: boolean
|
||||||
isPending: boolean
|
isPending: boolean
|
||||||
optional?: boolean
|
optional?: boolean
|
||||||
|
experimental?: boolean
|
||||||
children: ReactNode
|
children: ReactNode
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
@ -25,8 +27,21 @@ export default function ChecklistRow({
|
|||||||
loading={isPending}
|
loading={isPending}
|
||||||
/>
|
/>
|
||||||
<div className="flex flex-col min-w-0">
|
<div className="flex flex-col min-w-0">
|
||||||
<div className="font-bold dark:text-gray-300">
|
<div className={clsx(
|
||||||
|
'flex flex-wrap items-center gap-2',
|
||||||
|
'font-bold dark:text-gray-300',
|
||||||
|
)}>
|
||||||
{title}
|
{title}
|
||||||
|
{experimental &&
|
||||||
|
<span className={clsx(
|
||||||
|
'text-[0.7rem] font-medium uppercase tracking-wide leading-none',
|
||||||
|
'px-[3px] py-[2px] rounded-[0.2rem]',
|
||||||
|
'text-pink-500 dark:text-pink-800',
|
||||||
|
'bg-pink-50 dark:bg-pink-200/90',
|
||||||
|
'border border-pink-200/75 dark:border-pink-700/50',
|
||||||
|
)}>
|
||||||
|
Experimental
|
||||||
|
</span>}
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
{children}
|
{children}
|
||||||
|
|||||||
@ -37,6 +37,7 @@ export default function SiteChecklistClient({
|
|||||||
showFilmSimulations,
|
showFilmSimulations,
|
||||||
showExifInfo,
|
showExifInfo,
|
||||||
isProModeEnabled,
|
isProModeEnabled,
|
||||||
|
isStaticallyOptimized,
|
||||||
isBlurEnabled,
|
isBlurEnabled,
|
||||||
isGeoPrivacyEnabled,
|
isGeoPrivacyEnabled,
|
||||||
isPriorityOrderEnabled,
|
isPriorityOrderEnabled,
|
||||||
@ -274,6 +275,17 @@ export default function SiteChecklistClient({
|
|||||||
higher quality image storage:
|
higher quality image storage:
|
||||||
{renderEnvVars(['NEXT_PUBLIC_PRO_MODE'])}
|
{renderEnvVars(['NEXT_PUBLIC_PRO_MODE'])}
|
||||||
</ChecklistRow>
|
</ChecklistRow>
|
||||||
|
<ChecklistRow
|
||||||
|
title="Static Optimization"
|
||||||
|
status={isStaticallyOptimized}
|
||||||
|
isPending={isPendingPage}
|
||||||
|
optional
|
||||||
|
experimental
|
||||||
|
>
|
||||||
|
Set environment variable to {'"1"'} to enable
|
||||||
|
PPR and static optimization, i.e., building pages ahead of time:
|
||||||
|
{renderEnvVars(['NEXT_PUBLIC_STATICALLY_OPTIMIZE'])}
|
||||||
|
</ChecklistRow>
|
||||||
<ChecklistRow
|
<ChecklistRow
|
||||||
title="Image Blur"
|
title="Image Blur"
|
||||||
status={isBlurEnabled}
|
status={isBlurEnabled}
|
||||||
|
|||||||
@ -81,21 +81,31 @@ export const CURRENT_STORAGE: StorageType =
|
|||||||
|
|
||||||
// SETTINGS
|
// SETTINGS
|
||||||
|
|
||||||
export const PRO_MODE_ENABLED = process.env.NEXT_PUBLIC_PRO_MODE === '1';
|
export const PRO_MODE_ENABLED =
|
||||||
export const BLUR_ENABLED = process.env.NEXT_PUBLIC_BLUR_DISABLED !== '1';
|
process.env.NEXT_PUBLIC_PRO_MODE === '1';
|
||||||
export const GEO_PRIVACY_ENABLED = process.env.NEXT_PUBLIC_GEO_PRIVACY === '1';
|
export const STATICALLY_OPTIMIZED =
|
||||||
|
process.env.NEXT_PUBLIC_STATICALLY_OPTIMIZE === '1';
|
||||||
|
export const BLUR_ENABLED =
|
||||||
|
process.env.NEXT_PUBLIC_BLUR_DISABLED !== '1';
|
||||||
|
export const GEO_PRIVACY_ENABLED =
|
||||||
|
process.env.NEXT_PUBLIC_GEO_PRIVACY === '1';
|
||||||
export const PRIORITY_ORDER_ENABLED =
|
export const PRIORITY_ORDER_ENABLED =
|
||||||
process.env.NEXT_PUBLIC_IGNORE_PRIORITY_ORDER !== '1';
|
process.env.NEXT_PUBLIC_IGNORE_PRIORITY_ORDER !== '1';
|
||||||
export const PUBLIC_API_ENABLED = process.env.NEXT_PUBLIC_PUBLIC_API === '1';
|
export const PUBLIC_API_ENABLED =
|
||||||
export const SHOW_REPO_LINK = process.env.NEXT_PUBLIC_HIDE_REPO_LINK !== '1';
|
process.env.NEXT_PUBLIC_PUBLIC_API === '1';
|
||||||
|
export const SHOW_REPO_LINK =
|
||||||
|
process.env.NEXT_PUBLIC_HIDE_REPO_LINK !== '1';
|
||||||
export const SHOW_FILM_SIMULATIONS =
|
export const SHOW_FILM_SIMULATIONS =
|
||||||
process.env.NEXT_PUBLIC_HIDE_FILM_SIMULATIONS !== '1';
|
process.env.NEXT_PUBLIC_HIDE_FILM_SIMULATIONS !== '1';
|
||||||
export const SHOW_EXIF_DATA = process.env.NEXT_PUBLIC_HIDE_EXIF_DATA !== '1';
|
export const SHOW_EXIF_DATA =
|
||||||
export const GRID_ASPECT_RATIO = process.env.NEXT_PUBLIC_GRID_ASPECT_RATIO
|
process.env.NEXT_PUBLIC_HIDE_EXIF_DATA !== '1';
|
||||||
? parseFloat(process.env.NEXT_PUBLIC_GRID_ASPECT_RATIO)
|
export const GRID_ASPECT_RATIO =
|
||||||
: 1;
|
process.env.NEXT_PUBLIC_GRID_ASPECT_RATIO
|
||||||
|
? parseFloat(process.env.NEXT_PUBLIC_GRID_ASPECT_RATIO)
|
||||||
|
: 1;
|
||||||
export const OG_TEXT_BOTTOM_ALIGNMENT =
|
export const OG_TEXT_BOTTOM_ALIGNMENT =
|
||||||
(process.env.NEXT_PUBLIC_OG_TEXT_ALIGNMENT ?? '').toUpperCase() === 'BOTTOM';
|
(process.env.NEXT_PUBLIC_OG_TEXT_ALIGNMENT ?? '')
|
||||||
|
.toUpperCase() === 'BOTTOM';
|
||||||
|
|
||||||
export const HIGH_DENSITY_GRID = GRID_ASPECT_RATIO <= 1;
|
export const HIGH_DENSITY_GRID = GRID_ASPECT_RATIO <= 1;
|
||||||
|
|
||||||
@ -121,6 +131,7 @@ export const CONFIG_CHECKLIST_STATUS = {
|
|||||||
showFilmSimulations: SHOW_FILM_SIMULATIONS,
|
showFilmSimulations: SHOW_FILM_SIMULATIONS,
|
||||||
showExifInfo: SHOW_EXIF_DATA,
|
showExifInfo: SHOW_EXIF_DATA,
|
||||||
isProModeEnabled: PRO_MODE_ENABLED,
|
isProModeEnabled: PRO_MODE_ENABLED,
|
||||||
|
isStaticallyOptimized: STATICALLY_OPTIMIZED,
|
||||||
isBlurEnabled: BLUR_ENABLED,
|
isBlurEnabled: BLUR_ENABLED,
|
||||||
isGeoPrivacyEnabled: GEO_PRIVACY_ENABLED,
|
isGeoPrivacyEnabled: GEO_PRIVACY_ENABLED,
|
||||||
isPriorityOrderEnabled: PRIORITY_ORDER_ENABLED,
|
isPriorityOrderEnabled: PRIORITY_ORDER_ENABLED,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user