diff --git a/astro/src/components/photos/Album.astro b/astro/src/components/photos/Album.astro index 66e4b25..c26d3a7 100644 --- a/astro/src/components/photos/Album.astro +++ b/astro/src/components/photos/Album.astro @@ -42,7 +42,7 @@ album.photos.slice(sliceStartNumber, sliceEndNumber).forEach((photo) => {

{album.title}

- + { totalAlbumPages > 1 && ( (null); const [ containerHeight, setContainerHeight ] = useState(null); + console.log(LoadingSpinner); + useEffect(() => { setHasMounted(true); }, []); diff --git a/astro/src/components/photos/Photo.astro b/astro/src/components/photos/Photo.astro new file mode 100644 index 0000000..1dd84ef --- /dev/null +++ b/astro/src/components/photos/Photo.astro @@ -0,0 +1,71 @@ +--- +import { getAlbum } from '@/content/photos/albums'; +import { getSettings } from '@/content/settings/settings'; +import { getImageUrl } from '@/lib/images'; +import { getAlbumRoute, getPhotoRoute } from '@/lib/routing'; + +interface Props { + page: PhotoPage; +} + +const photo = Astro.props.page; + +const settings = await getSettings(); +const album = await getAlbum(settings, photo.album.url); + +const photoIndex = album.photos.findIndex(p => p.id === photo.id); + +let previousUrl: string | null = null; +let nextUrl: string | null = null; + +// Check for previous photo +if (photoIndex > 0) { + previousUrl = getPhotoRoute(settings.photo, album, album.photos[photoIndex - 1]); +} + +// Check for next photo +if (photoIndex + 1 < album.photos.length) { + nextUrl = getPhotoRoute(settings.photo, album, album.photos[photoIndex + 1]); +} + +const albumPageNumber = Math.ceil((photoIndex + 1) / settings.photo.album.perPage); +const returnUrl = albumPageNumber > 1 + ? `${getAlbumRoute(settings.photo, album)}/${albumPageNumber}` + : getAlbumRoute(settings.photo, album); +--- + +
+
+ {photo.text +
+ +
+ Return +
+ + { photo.text !== null && ( +
{photo.text.trim()}
+ ) } + + { previousUrl !== null && ( + + Previous + + ) } + + { nextUrl !== null && ( + + Next + + ) } +
diff --git a/astro/src/layouts/PhotoLayout.astro b/astro/src/layouts/PhotoLayout.astro index 11e8640..fdff439 100644 --- a/astro/src/layouts/PhotoLayout.astro +++ b/astro/src/layouts/PhotoLayout.astro @@ -76,9 +76,7 @@ const css = { - + - -