feat: allow subpages to override title and add subtitle in gallery.yaml

This commit is contained in:
ralksta
2026-03-08 22:46:27 +01:00
parent 88f03fe2ce
commit 32bb6cb2ca
6 changed files with 57 additions and 34 deletions

1
.gitignore vendored
View File

@@ -31,6 +31,7 @@ npm-debug.log*
yarn-debug.log* yarn-debug.log*
yarn-error.log* yarn-error.log*
.pnpm-debug.log* .pnpm-debug.log*
server.log
# env files (can opt-in for committing if needed) # env files (can opt-in for committing if needed)
.env* .env*

View File

@@ -17,12 +17,21 @@ interface Placeholder {
interface SubpageGridViewProps { interface SubpageGridViewProps {
slug: string; slug: string;
title?: string;
subtitle?: string;
albums: SubpageAlbum[]; albums: SubpageAlbum[];
coverPlaceholders: (Placeholder | null)[]; coverPlaceholders: (Placeholder | null)[];
} }
export function SubpageGridView({ slug, albums, coverPlaceholders }: SubpageGridViewProps) { export function SubpageGridView({ slug, title, subtitle, albums, coverPlaceholders }: SubpageGridViewProps) {
return ( return (
<div className="subpage-container">
{(title || subtitle) && (
<header className="subpage-header">
{title && <h1 className="subpage-title">{title}</h1>}
{subtitle && <p className="subpage-subtitle">{subtitle}</p>}
</header>
)}
<div className="subpage-grid"> <div className="subpage-grid">
{albums.map((album, i) => { {albums.map((album, i) => {
const ph = coverPlaceholders[i]; const ph = coverPlaceholders[i];
@@ -58,5 +67,6 @@ export function SubpageGridView({ slug, albums, coverPlaceholders }: SubpageGrid
); );
})} })}
</div> </div>
</div>
); );
} }

View File

@@ -222,6 +222,8 @@ export default async function PathPage({ params }: PathPageProps) {
return ( return (
<SubpageGridView <SubpageGridView
slug={slug} slug={slug}
title={result.subpage.title || result.subpage.name}
subtitle={result.subpage.subtitle}
albums={albums} albums={albums}
coverPlaceholders={coverPlaceholders} coverPlaceholders={coverPlaceholders}
/> />

View File

@@ -18,6 +18,8 @@ subpages:
- "album-uuid-3" - "album-uuid-3"
- "album-uuid-4" - "album-uuid-4"
"Projects": "Projects":
title: "My Creative Projects" # Optional: Header title, defaults to Navigation key ("Projects")
subtitle: "A collection of 2026 highlights in 35mm film." # Optional: Sub-text for headers
password: "your-password" # Optional protection password: "your-password" # Optional protection
albums: albums:
- "album-uuid-5" - "album-uuid-5"

View File

@@ -78,6 +78,8 @@ export function getConfig(): AppConfig {
return { return {
name: sp.name, name: sp.name,
slug: slugify(sp.name), slug: slugify(sp.name),
title: sp.title,
subtitle: sp.subtitle,
albumIds: sp.albums.map((entry) => processAlbumEntry(entry, `subpage "${sp.name}"`)), albumIds: sp.albums.map((entry) => processAlbumEntry(entry, `subpage "${sp.name}"`)),
password: sp.password, password: sp.password,
...(sp.grid ? { ...(sp.grid ? {
@@ -95,12 +97,14 @@ export function getConfig(): AppConfig {
if (Array.isArray(value)) { if (Array.isArray(value)) {
return { name, slug: slugify(name), albumIds: value.map((entry) => processAlbumEntry(entry, `subpage "${name}"`)) }; return { name, slug: slugify(name), albumIds: value.map((entry) => processAlbumEntry(entry, `subpage "${name}"`)) };
} }
interface SubpageObjectValue { albums?: Array<string | Record<string, string>>; password?: string; grid?: { columns?: number; gap?: number; aspectRatio?: string; layout?: string; }; } interface SubpageObjectValue { title?: string; subtitle?: string; albums?: Array<string | Record<string, string>>; password?: string; grid?: { columns?: number; gap?: number; aspectRatio?: string; layout?: string; }; }
const sp = value as SubpageObjectValue; const sp = value as SubpageObjectValue;
const albumEntries = sp.albums || []; const albumEntries = sp.albums || [];
return { return {
name, name,
slug: slugify(name), slug: slugify(name),
title: sp.title,
subtitle: sp.subtitle,
albumIds: albumEntries.map((entry) => processAlbumEntry(entry, `subpage "${name}"`)), albumIds: albumEntries.map((entry) => processAlbumEntry(entry, `subpage "${name}"`)),
password: sp.password, password: sp.password,
...(sp.grid ? { ...(sp.grid ? {

View File

@@ -1,6 +1,8 @@
export interface SubpageConfig { export interface SubpageConfig {
name: string; name: string;
slug: string; slug: string;
title?: string;
subtitle?: string;
albumIds: string[]; albumIds: string[];
password?: string; password?: string;
grid?: Partial<GridConfig>; grid?: Partial<GridConfig>;
@@ -79,6 +81,8 @@ export interface GalleryYaml {
| Record<string, string[] | Array<string | Record<string, string>>> | Record<string, string[] | Array<string | Record<string, string>>>
| Array<{ | Array<{
name: string; name: string;
title?: string;
subtitle?: string;
albums: Array<string | Record<string, string>>; albums: Array<string | Record<string, string>>;
password?: string; password?: string;
grid?: { grid?: {