feat: increase gallery grid from 4 to 5 columns per row on desktopfeat: increase gallery grid from 4 to 5 columns per row on desktop

This commit is contained in:
2026-02-25 19:11:23 +01:00
parent 5c97488e80
commit 0032aec02f
131 changed files with 15674 additions and 597 deletions

View File

@@ -0,0 +1,43 @@
/**
* useNavContext
*
* Provides prev/next artwork IDs scoped to the same author via API.
*/
import { useCallback } from 'react';
// Module-level cache for API calls
const fallbackCache = new Map();
async function fetchFallback(artworkId) {
const key = String(artworkId);
if (fallbackCache.has(key)) return fallbackCache.get(key);
try {
const res = await fetch(`/api/artworks/navigation/${artworkId}`, {
headers: { Accept: 'application/json' },
});
if (!res.ok) return { prevId: null, nextId: null, prevUrl: null, nextUrl: null };
const data = await res.json();
const result = {
prevId: data.prev_id ?? null,
nextId: data.next_id ?? null,
prevUrl: data.prev_url ?? null,
nextUrl: data.next_url ?? null,
};
fallbackCache.set(key, result);
return result;
} catch {
return { prevId: null, nextId: null, prevUrl: null, nextUrl: null };
}
}
export function useNavContext(currentArtworkId) {
/**
* Always resolve via API to guarantee same-user navigation.
*/
const getNeighbors = useCallback(async () => {
return fetchFallback(currentArtworkId);
}, [currentArtworkId]);
return { getNeighbors };
}