jedmund-svelte/src/routes/albums/[slug]/+page.ts
Justin Edmund 2bbc306762 refactor: restructure routing - albums at /albums/[slug], photos at /photos/[id]
- Move album routes from /photos/[slug] to /albums/[slug]
- Simplify photo permalinks from /photos/p/[id] to /photos/[id]
- Remove album-scoped photo route /photos/[albumSlug]/[photoId]
- Update all component references to use new routes
- Simplify content.ts to always use direct photo permalinks
- Update PhotoItem, MasonryPhotoGrid, ThreeColumnPhotoGrid components
- Update UniverseAlbumCard and admin AlbumForm view links
- Remove album context from photo navigation

Breaking change: URLs have changed
- Albums: /photos/[slug] → /albums/[slug]
- Photos: /photos/p/[id] → /photos/[id]

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-24 10:35:21 +01:00

29 lines
682 B
TypeScript

import type { PageLoad } from './$types'
export const load: PageLoad = async ({ params, fetch }) => {
try {
// Fetch album by slug
const albumResponse = await fetch(`/api/albums/by-slug/${params.slug}`)
if (albumResponse.ok) {
const album = await albumResponse.json()
// Check if album is published
if (album.status === 'published') {
return {
album
}
} else {
throw new Error('Album not published')
}
}
// Album not found
throw new Error('Album not found')
} catch (error) {
console.error('Error loading album:', error)
return {
album: null,
error: error instanceof Error ? error.message : 'Failed to load album'
}
}
}