fix: replace any types in route pages (10 errors)
Phase 1 Batch 3: Route Pages type safety improvements Fixed 10 any-type errors across 7 route page files: 1. src/routes/+page.ts (1 error) - Added PaginationInfo interface for fetchProjects return type 2. src/routes/admin/+layout.svelte (1 error) - Changed children prop from any to Snippet type 3. src/routes/admin/albums/+page.svelte (1 error) - Changed Album.content from any to EditorData type 4. src/routes/admin/universe/+page.svelte (1 error) - Changed form prop from any to Record<string, unknown> | null | undefined 5. src/routes/albums/[slug]/+page.svelte (4 errors) - Added AlbumPhoto and AlbumData interfaces - Fixed photo map parameters to use AlbumPhoto - Fixed extractContentPreview to accept EditorData | null - Fixed generateAlbumJsonLd to accept AlbumData 6. src/routes/albums/+page.svelte (1 error) - Changed coverPhoto.colors from any to ColorPalette[] 7. src/routes/photos/[id]/+page.svelte (1 error) - Changed navigateToPhoto parameter from any to PhotoItem | null Progress: 67 any-type errors remaining (down from 77)
This commit is contained in:
parent
9da0232d45
commit
f31d02d51c
7 changed files with 44 additions and 11 deletions
|
|
@ -40,9 +40,16 @@ async function fetchRecentAlbums(fetch: typeof window.fetch): Promise<Album[]> {
|
||||||
return musicData.albums
|
return musicData.albums
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface PaginationInfo {
|
||||||
|
total: number
|
||||||
|
limit: number
|
||||||
|
offset: number
|
||||||
|
hasMore: boolean
|
||||||
|
}
|
||||||
|
|
||||||
async function fetchProjects(
|
async function fetchProjects(
|
||||||
fetch: typeof window.fetch
|
fetch: typeof window.fetch
|
||||||
): Promise<{ projects: Project[]; pagination: any }> {
|
): Promise<{ projects: Project[]; pagination: PaginationInfo | null }> {
|
||||||
const response = await fetch(
|
const response = await fetch(
|
||||||
'/api/projects?projectType=work&includeListOnly=true&includePasswordProtected=true'
|
'/api/projects?projectType=work&includeListOnly=true&includePasswordProtected=true'
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,9 @@
|
||||||
import { page } from '$app/stores'
|
import { page } from '$app/stores'
|
||||||
import AdminNavBar from '$lib/components/admin/AdminNavBar.svelte'
|
import AdminNavBar from '$lib/components/admin/AdminNavBar.svelte'
|
||||||
import type { LayoutData } from './$types'
|
import type { LayoutData } from './$types'
|
||||||
|
import type { Snippet } from 'svelte'
|
||||||
|
|
||||||
const { children, data } = $props<{ children: any; data: LayoutData }>()
|
const { children, data } = $props<{ children: Snippet; data: LayoutData }>()
|
||||||
|
|
||||||
const currentPath = $derived($page.url.pathname)
|
const currentPath = $derived($page.url.pathname)
|
||||||
const isLoginRoute = $derived(currentPath === '/admin/login')
|
const isLoginRoute = $derived(currentPath === '/admin/login')
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@
|
||||||
import ErrorMessage from '$lib/components/admin/ErrorMessage.svelte'
|
import ErrorMessage from '$lib/components/admin/ErrorMessage.svelte'
|
||||||
import Button from '$lib/components/admin/Button.svelte'
|
import Button from '$lib/components/admin/Button.svelte'
|
||||||
import Select from '$lib/components/admin/Select.svelte'
|
import Select from '$lib/components/admin/Select.svelte'
|
||||||
|
import type { EditorData } from '$lib/types/editor'
|
||||||
|
|
||||||
interface Photo {
|
interface Photo {
|
||||||
id: number
|
id: number
|
||||||
|
|
@ -32,7 +33,7 @@
|
||||||
createdAt: string
|
createdAt: string
|
||||||
updatedAt: string
|
updatedAt: string
|
||||||
photos: Photo[]
|
photos: Photo[]
|
||||||
content?: any
|
content?: EditorData
|
||||||
_count: {
|
_count: {
|
||||||
media: number
|
media: number
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
import type { PageData } from '../posts/$types'
|
import type { PageData } from '../posts/$types'
|
||||||
|
|
||||||
export let data: PageData
|
export let data: PageData
|
||||||
export let form: any
|
export let form: Record<string, unknown> | null | undefined
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<PostsPage {data} {form} />
|
<PostsPage {data} {form} />
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@
|
||||||
import { generateMetaTags } from '$lib/utils/metadata'
|
import { generateMetaTags } from '$lib/utils/metadata'
|
||||||
import { page } from '$app/stores'
|
import { page } from '$app/stores'
|
||||||
import type { PageData } from './$types'
|
import type { PageData } from './$types'
|
||||||
|
import type { ColorPalette } from '$lib/types/photos'
|
||||||
|
|
||||||
interface Album {
|
interface Album {
|
||||||
id: string
|
id: string
|
||||||
|
|
@ -21,7 +22,7 @@
|
||||||
width?: number
|
width?: number
|
||||||
height?: number
|
height?: number
|
||||||
dominantColor?: string
|
dominantColor?: string
|
||||||
colors?: any
|
colors?: ColorPalette[]
|
||||||
aspectRatio?: number
|
aspectRatio?: number
|
||||||
caption?: string
|
caption?: string
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,29 @@
|
||||||
import { renderEdraContent, getContentExcerpt } from '$lib/utils/content'
|
import { renderEdraContent, getContentExcerpt } from '$lib/utils/content'
|
||||||
import { page } from '$app/stores'
|
import { page } from '$app/stores'
|
||||||
import type { PageData } from './$types'
|
import type { PageData } from './$types'
|
||||||
|
import type { EditorData } from '$lib/types/editor'
|
||||||
|
|
||||||
|
interface AlbumPhoto {
|
||||||
|
id: number
|
||||||
|
url: string
|
||||||
|
caption: string | null
|
||||||
|
filename: string
|
||||||
|
width: number | null
|
||||||
|
height: number | null
|
||||||
|
}
|
||||||
|
|
||||||
|
interface AlbumData {
|
||||||
|
id: number
|
||||||
|
slug: string
|
||||||
|
title: string
|
||||||
|
description: string | null
|
||||||
|
content: EditorData | null
|
||||||
|
location: string | null
|
||||||
|
date: string | null
|
||||||
|
createdAt: string
|
||||||
|
updatedAt: string
|
||||||
|
photos?: AlbumPhoto[]
|
||||||
|
}
|
||||||
|
|
||||||
let { data }: { data: PageData } = $props()
|
let { data }: { data: PageData } = $props()
|
||||||
|
|
||||||
|
|
@ -14,7 +37,7 @@
|
||||||
|
|
||||||
// Transform album data to PhotoItem format for MasonryPhotoGrid
|
// Transform album data to PhotoItem format for MasonryPhotoGrid
|
||||||
const photoItems = $derived(
|
const photoItems = $derived(
|
||||||
album?.photos?.map((photo: any) => ({
|
album?.photos?.map((photo: AlbumPhoto) => ({
|
||||||
id: `photo-${photo.id}`,
|
id: `photo-${photo.id}`,
|
||||||
src: photo.url,
|
src: photo.url,
|
||||||
alt: photo.caption || photo.filename,
|
alt: photo.caption || photo.filename,
|
||||||
|
|
@ -36,7 +59,7 @@
|
||||||
const pageUrl = $derived($page.url.href)
|
const pageUrl = $derived($page.url.href)
|
||||||
|
|
||||||
// Helper to get content preview using Edra content excerpt utility
|
// Helper to get content preview using Edra content excerpt utility
|
||||||
const extractContentPreview = (content: any): string => {
|
const extractContentPreview = (content: EditorData | null): string => {
|
||||||
if (!content) return ''
|
if (!content) return ''
|
||||||
return getContentExcerpt(content, 155)
|
return getContentExcerpt(content, 155)
|
||||||
}
|
}
|
||||||
|
|
@ -65,13 +88,13 @@
|
||||||
)
|
)
|
||||||
|
|
||||||
// Generate enhanced JSON-LD for albums with content
|
// Generate enhanced JSON-LD for albums with content
|
||||||
const generateAlbumJsonLd = (album: any, pageUrl: string) => {
|
const generateAlbumJsonLd = (album: AlbumData, pageUrl: string) => {
|
||||||
const baseJsonLd = generateImageGalleryJsonLd({
|
const baseJsonLd = generateImageGalleryJsonLd({
|
||||||
name: album.title,
|
name: album.title,
|
||||||
description: album.description,
|
description: album.description,
|
||||||
url: pageUrl,
|
url: pageUrl,
|
||||||
images:
|
images:
|
||||||
album.photos?.map((photo: any) => ({
|
album.photos?.map((photo: AlbumPhoto) => ({
|
||||||
url: photo.url,
|
url: photo.url,
|
||||||
caption: photo.caption
|
caption: photo.caption
|
||||||
})) || []
|
})) || []
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
import { spring } from 'svelte/motion'
|
import { spring } from 'svelte/motion'
|
||||||
import { getCurrentMousePosition } from '$lib/stores/mouse'
|
import { getCurrentMousePosition } from '$lib/stores/mouse'
|
||||||
import type { PageData } from './$types'
|
import type { PageData } from './$types'
|
||||||
import { isAlbum } from '$lib/types/photos'
|
import { isAlbum, type PhotoItem } from '$lib/types/photos'
|
||||||
import ArrowLeft from '$icons/arrow-left.svg'
|
import ArrowLeft from '$icons/arrow-left.svg'
|
||||||
import ArrowRight from '$icons/arrow-right.svg'
|
import ArrowRight from '$icons/arrow-right.svg'
|
||||||
|
|
||||||
|
|
@ -110,7 +110,7 @@
|
||||||
})
|
})
|
||||||
|
|
||||||
// Handle photo navigation
|
// Handle photo navigation
|
||||||
function navigateToPhoto(item: any) {
|
function navigateToPhoto(item: PhotoItem | null) {
|
||||||
if (!item) return
|
if (!item) return
|
||||||
// Extract media ID from item.id (could be 'media-123' or 'photo-123')
|
// Extract media ID from item.id (could be 'media-123' or 'photo-123')
|
||||||
const mediaId = item.id.replace(/^(media|photo)-/, '')
|
const mediaId = item.id.replace(/^(media|photo)-/, '')
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue