feat: add branded editorial photo catalog

This commit is contained in:
Leon Tonhäuser committed 2026-08-09 22:22:31 +02:00
1 parent f6e6018cc1
commit 66f0599653
20 files changed
+1299 -36

No files matched your search

+104
View File
@@ -0,0 +1,104 @@
import Link from "next/link";
import { notFound } from "next/navigation";
import { AlbumCatalogError, albumCatalog } from "@/modules/albums/catalog";
import { PhotoContactSheet } from "@/modules/albums/catalog-content";
import { requireEditorial } from "../../access";
type AlbumPageProps = Readonly<{
params: Promise<{ albumId: string }>;
searchParams: Promise<{ page?: string | string[]; suche?: string | string[] }>;
}>;
export default async function AlbumPage({ params, searchParams }: AlbumPageProps) {
const [{ albumId }, rawSearchParams, principal] = await Promise.all([
params,
searchParams,
requireEditorial(),
]);
const query = normalizedQuery(singleValue(rawSearchParams.suche));
const result = await loadAlbumPage({
editorialId: principal.editorialId,
albumId,
query,
page: singleValue(rawSearchParams.page),
});
if (result.unavailable) {
return <ImmichUnavailable />;
}
if (!result.album) {
notFound();
}
return (
<section className="editorial-section" aria-labelledby="album-title">
<p className="editorial-kicker">Bildarchiv · {result.album.assetCount} freigegebene Fotos</p>
<div className="editorial-title-row album-title-row">
<h1 id="album-title">{result.album.albumName}</h1>
<Link className="quiet-link" href="/redaktion/alben">
Alle Alben
</Link>
</div>
<PhotoContactSheet
albumId={result.album.id}
albumName={result.album.albumName}
page={result.page}
query={query}
/>
</section>
);
}
async function loadAlbumPage({
editorialId,
albumId,
query,
page,
}: {
editorialId: string;
albumId: string;
query: string;
page: string | undefined;
}) {
try {
const albums = await albumCatalog.getVisibleAlbums(editorialId);
const album = albums.find((candidate) => candidate.id === albumId);
if (!album) {
return { album: null, page: null, unavailable: false as const };
}
const results = await albumCatalog.searchVisiblePhotos(editorialId, {
requestedAlbumId: album.id,
description: query,
page,
});
return { album, page: results, unavailable: false as const };
} catch (error) {
if (error instanceof AlbumCatalogError && error.code === "IMMICH_UNAVAILABLE") {
return { album: null, page: null, unavailable: true as const };
}
throw error;
}
}
function singleValue(value: string | string[] | undefined): string | undefined {
return typeof value === "string" ? value : undefined;
}
function normalizedQuery(value: string | undefined): string {
return (value ?? "").replace(/\s+/g, " ").trim().slice(0, 200);
}
function ImmichUnavailable() {
return (
<section className="editorial-section editorial-state" aria-labelledby="album-title">
<p className="editorial-kicker">Bildarchiv</p>
<h1 id="album-title">Fotos momentan nicht erreichbar</h1>
<p role="status">Bitte laden Sie diese Seite in wenigen Minuten erneut.</p>
<Link className="quiet-link" href="/redaktion/alben">
Zurück zu den Alben
</Link>
</section>
);
}