diff --git a/app/about/edit/page.tsx b/app/about/edit/page.tsx index 02f22404..098200a9 100644 --- a/app/about/edit/page.tsx +++ b/app/about/edit/page.tsx @@ -1,53 +1,9 @@ import AdminAboutEditPage from '@/about/AdminAboutEditPage'; import { getAboutData } from '@/about/data'; -import { PRESERVE_ORIGINAL_UPLOADS } from '@/app/config'; -import { feedQueryOptions } from '@/feed'; -import { - getPhotosCached, - getPhotosMetaCached, -} from '@/photo/cache'; -import { TAG_FAVS } from '@/tag'; - -const PHOTO_CHOOSER_QUERY_OPTIONS = feedQueryOptions({ - isGrid: true, - excludeFromFeeds: false, -}); export default async function AboutEditPage() { - const [ - { - about, - photoAvatar, - photoHero, - }, - photos, - photosCount, - photosFavs, - ] = await Promise.all([ - getAboutData() - .catch(() => ({ - about: undefined, - photoAvatar: undefined, - photoHero: undefined, - })), - getPhotosCached(PHOTO_CHOOSER_QUERY_OPTIONS) - .catch(() => []), - getPhotosMetaCached(PHOTO_CHOOSER_QUERY_OPTIONS) - .then(({ count }) => count) - .catch(() => 0), - getPhotosCached({ tag: TAG_FAVS }) - .catch(() => []), - ]); + const { about } = await getAboutData() + .catch(() => ({ about: undefined })); - return ( - - ); + return ; } diff --git a/app/about/page.tsx b/app/about/page.tsx index 86fb192c..3e8ef922 100644 --- a/app/about/page.tsx +++ b/app/about/page.tsx @@ -1,18 +1,13 @@ import AboutPageClient from '@/about/AboutPageClient'; import { getAboutDataCached } from '@/about/data'; -import { ABOUT_DESCRIPTION_DEFAULT, SHOW_ABOUT_PAGE } from '@/app/config'; -import { PATH_ROOT } from '@/app/path'; -import { getDataForCategoriesCached } from '@/category/cache'; import { - getLastModifiedForCategories, - NULL_CATEGORY_DATA, -} from '@/category/data'; -import { getPhotosMetaCached } from '@/photo/cache'; -import PhotosEmptyState from '@/photo/PhotosEmptyState'; -import { getAllPhotoIdsWithUpdatedAt } from '@/photo/query'; -import { TAG_FAVS } from '@/tag'; + ABOUT_DESCRIPTION_DEFAULT, + ABOUT_SUBHEAD, + ABOUT_TITLE, + SHOW_ABOUT_PAGE, +} from '@/app/config'; +import { PATH_ROOT } from '@/app/path'; import { safelyParseFormattedHtml } from '@/utility/html'; -import { max } from 'date-fns'; import { redirect } from 'next/navigation'; export const dynamic = 'force-static'; @@ -20,75 +15,27 @@ export const dynamic = 'force-static'; export default async function AboutPage() { if (!SHOW_ABOUT_PAGE) { redirect(PATH_ROOT); } - const [ - { - about, - photoAvatar, - photoHero, - }, - photosMeta, - photos, - categories, - ] = await Promise.all([ - getAboutDataCached() - .catch(() => ({ - about: undefined, - photoAvatar: undefined, - photoHero: undefined, - })), - getPhotosMetaCached().catch(() => {}), - getAllPhotoIdsWithUpdatedAt().catch(() => []), - getDataForCategoriesCached().catch(() => (NULL_CATEGORY_DATA)), - ]); + const { about } = await getAboutDataCached() + .catch(() => ({ about: undefined })); + const title = about?.title || ABOUT_TITLE; + const subhead = about?.subhead || ABOUT_SUBHEAD; const description = about?.description || ABOUT_DESCRIPTION_DEFAULT; const descriptionHtml = description ?
: undefined; - const { - cameras, - lenses, - albums, - tags, - recipes, - films, - } = categories; - - const place = albums - .slice() - .sort((a, b) => b.count - a.count)[0]?.album.location; - - const lastModifiedSite = max([ - getLastModifiedForCategories(categories, photos), - about?.updatedAt, - ].filter(date => date instanceof Date)); - return ( - (photosMeta?.count ?? 0) > 0 - ? tag !== TAG_FAVS)[0]?.tag} - place={place} - album={albums[0]?.album} - lastUpdated={lastModifiedSite} - /> - : + ); } diff --git a/src/about/AboutPageClient.tsx b/src/about/AboutPageClient.tsx index 5664bd44..c2c1ead2 100644 --- a/src/about/AboutPageClient.tsx +++ b/src/about/AboutPageClient.tsx @@ -1,194 +1,45 @@ 'use client'; -import PhotoAlbum from '@/album/PhotoAlbum'; import { useAppState } from '@/app/AppState'; -import PhotoCamera from '@/camera/PhotoCamera'; import AnimateItems from '@/components/AnimateItems'; import AppGrid from '@/components/AppGrid'; -import PhotoFilm from '@/film/PhotoFilm'; -import PhotoLens from '@/lens/PhotoLens'; -import { Photo } from '@/photo'; -import PhotoRecipe from '@/recipe/PhotoRecipe'; -import PhotoTag from '@/tag/PhotoTag'; -import clsx from 'clsx/lite'; -import { formatDistanceToNowStrict } from 'date-fns'; -import AdminAboutMenu from './AdminAboutMenu'; -import PhotoLarge from '@/photo/PhotoLarge'; -import { ReactNode, useMemo } from 'react'; -import { Camera } from '@/camera'; -import { Lens } from '@/lens'; -import { Album } from '@/album'; +import { ReactNode } from 'react'; import { useAppText } from '@/i18n/state/client'; -import PhotoAvatar from '@/photo/PhotoAvatar'; import Link from 'next/link'; import { PATH_ADMIN_ABOUT_EDIT } from '@/app/path'; -import { LuCirclePlus, LuUser } from 'react-icons/lu'; +import { LuCirclePlus } from 'react-icons/lu'; import AdminEmptyState from '@/admin/AdminEmptyState'; -import { Place } from '@/place'; -import PlaceEntity from '@/place/PlaceEntity'; +import AdminAboutMenu from './AdminAboutMenu'; +import clsx from 'clsx/lite'; export default function AboutPageClient({ title, subhead, descriptionHtml, - photosCount = 0, - photosOldest, - photoAvatar, - photoHero, - camera, - lens, - recipe, - film, - tag, - place, - album, - lastUpdated, }: { title?: string subhead?: string descriptionHtml?: ReactNode - photosCount?: number - photosOldest?: string - photoAvatar?: Photo - photoHero?: Photo - camera?: Camera - lens?: Lens - recipe?: string - film?: string - tag?: string - place?: Place - album?: Album - lastUpdated?: Date }) { - const { - isUserSignedIn, - } = useAppState(); - + const { isUserSignedIn } = useAppState(); const appText = useAppText(); - const renderItem = (label: string, content?: ReactNode) => ( -
-
- {label} -
-
- {content || '--'} -
-
- ); - - const items = useMemo(() => [ - renderItem( - appText.about.photoCount, - photosCount.toString().padStart(4, '0'), - ), - renderItem( - appText.about.firstPhoto, - photosOldest?.slice(0, 10), - ), - camera && renderItem( - appText.about.topCamera, - , - ), - lens && renderItem( - appText.about.topLens, - , - ), - recipe && renderItem( - appText.about.topRecipe, - , - ), - film && renderItem( - appText.about.topFilm, - , - ), - tag && renderItem( - appText.about.popularTag, - , - ), - place && renderItem( - appText.about.popularPlace, - , - ), - album && renderItem( - appText.about.recentAlbum, - , - ), - ].filter(Boolean), [ - appText.about, - photosCount, - photosOldest, - camera, - lens, - recipe, - film, - album, - place, - tag, - ]); - return ( -
- } - /> -
-
-
- {title || appText.about.titleDefault} -
- {subhead && -
{subhead}
} -
- {lastUpdated &&
- {appText.about.updated( - formatDistanceToNowStrict(lastUpdated), - )} -
} + contentMain={
+
+
+

+ {title || appText.about.titleDefault} +

+ {subhead && +

{subhead}

}
{isUserSignedIn && }
@@ -207,21 +58,10 @@ export default function AboutPageClient({ includeContainer={false} className="gap-3! p-6!" > - Add optional description + Add description } -
} /> - {photoHero && - }
]} /> ); diff --git a/src/about/AdminAboutEditPage.tsx b/src/about/AdminAboutEditPage.tsx index 5ad508e3..a8e5fb8b 100644 --- a/src/about/AdminAboutEditPage.tsx +++ b/src/about/AdminAboutEditPage.tsx @@ -8,26 +8,13 @@ import FieldsetWithStatus from '@/components/FieldsetWithStatus'; import AdminChildPage from '@/components/AdminChildPage'; import { updateAboutAction } from './actions'; import SubmitButtonWithStatus from '@/components/SubmitButtonWithStatus'; -import { Photo } from '@/photo'; import { useAppText } from '@/i18n/state/client'; -import FieldsetPhotoChooser from '@/photo/form/FieldsetPhotoChooser'; -import { ABOUT_DESCRIPTION_DEFAULT } from '@/app/config'; +import { ABOUT_DESCRIPTION_DEFAULT, ABOUT_SUBHEAD, ABOUT_TITLE } from '@/app/config'; export default function AdminAboutEditPage({ about, - photoAvatar, - photoHero, - photos, - photosCount, - photosFavs, }: { about?: About - photoAvatar?: Photo - photoHero?: Photo - photos: Photo[] - photosCount: number - photosFavs: Photo[] - shouldResizeImages?: boolean }) { const appText = useAppText(); @@ -40,32 +27,21 @@ export default function AdminAboutEditPage({ breadcrumb="Edit About Page" >
- setAboutForm(form => - ({ ...form, photoIdAvatar }))} - photo={photoAvatar} - photos={photos} - photosCount={photosCount} - photosFavs={photosFavs} - /> setAboutForm(form => ({ ...form, title }))} /> setAboutForm(form => ({ ...form, subhead }))} /> @@ -77,17 +53,9 @@ export default function AdminAboutEditPage({ onChange={description => setAboutForm(form => ({ ...form, description }))} /> - setAboutForm(form => - ({ ...form, photoIdHero }))} - photo={photoHero} - photos={photos} - photosCount={photosCount} - photosFavs={photosFavs} - /> +

+ Supports simple formatting: <b>, <i>, <u>, <br> +

- about?.photoIdAvatar - ? getPhotoCached(about?.photoIdAvatar ?? '', true) - : undefined; - -const getAboutHero = (about?: About) => - about?.photoIdHero - ? getPhotoCached(about?.photoIdHero ?? '', true) - // Fall back to favorite photos if no hero photo is set - : getPhotosCached({ tag: TAG_FAVS, limit: 1 }) - .then(photos => photos.length > 0 - ? photos[0] - // Fall back to oldest photo if no favorite photos exist - : getPhotosCached({ limit: 1, sortBy: 'takenAtAsc' }) - .then(photos => photos[0])); - export const getAboutData = () => getAbout() - .then(async about => ({ - about, - photoAvatar: await getAboutAvatar(about), - photoHero: await getAboutHero(about), - })); + .then(about => ({ about })); export const getAboutDataCached = () => getAboutCached() - .then(async about => ({ - about, - photoAvatar: await getAboutAvatar(about), - photoHero: await getAboutHero(about), - })); + .then(about => ({ about })); diff --git a/src/app/config.ts b/src/app/config.ts index 72f05bd8..f55d4577 100644 --- a/src/app/config.ts +++ b/src/app/config.ts @@ -153,9 +153,17 @@ export const SIDEBAR_TEXT = process.env.NEXT_PUBLIC_PAGE_ABOUT || process.env.NEXT_PUBLIC_SITE_ABOUT; +export const ABOUT_TITLE = + process.env.NEXT_PUBLIC_ABOUT_TITLE || + NAV_TITLE; + +export const ABOUT_SUBHEAD = + process.env.NEXT_PUBLIC_ABOUT_SUBHEAD; + export const ABOUT_DESCRIPTION_DEFAULT = - process.env.NEXT_PUBLIC_META_DESCRIPTION || - process.env.NEXT_PUBLIC_SIDEBAR_TEXT; + process.env.NEXT_PUBLIC_ABOUT_DESCRIPTION || + process.env.NEXT_PUBLIC_SIDEBAR_TEXT || + process.env.NEXT_PUBLIC_META_DESCRIPTION; // STORAGE