mirror of
https://github.com/Afilmory/afilmory
synced 2026-02-01 22:48:17 +00:00
- Changed the PhotoManifest type to PhotoManifestItem across various components and services for consistency. - Removed the views property from the PhotoInfo interface to streamline photo data. - Updated rules in color.mdc and project.mdc to adjust glob patterns and application behavior. - Enhanced the feed-sitemap plugin to utilize the new PhotoManifestItem type for better data management. Signed-off-by: Innei <tukon479@gmail.com>
38 lines
1.0 KiB
TypeScript
38 lines
1.0 KiB
TypeScript
import { readFileSync } from 'node:fs'
|
|
import { join } from 'node:path'
|
|
|
|
import { workdir } from '../packages/builder/src/path.js'
|
|
import type { PhotoManifestItem } from '../packages/builder/src/types/photo.js'
|
|
|
|
class BuildTimePhotoLoader {
|
|
private photos: PhotoManifestItem[] = []
|
|
private photoMap: Record<string, PhotoManifestItem> = {}
|
|
|
|
constructor() {
|
|
try {
|
|
const manifestPath = join(workdir, 'src/data/photos-manifest.json')
|
|
const manifestContent = readFileSync(manifestPath, 'utf-8')
|
|
this.photos = JSON.parse(manifestContent).data as PhotoManifestItem[]
|
|
|
|
this.photos.forEach((photo) => {
|
|
this.photoMap[photo.id] = photo
|
|
})
|
|
|
|
console.info(`📚 Loaded ${this.photos.length} photos from manifest`)
|
|
} catch (error) {
|
|
console.error('❌ Failed to load photos manifest:', error)
|
|
this.photos = []
|
|
}
|
|
}
|
|
|
|
getPhotos() {
|
|
return this.photos
|
|
}
|
|
|
|
getPhoto(id: string) {
|
|
return this.photoMap[id]
|
|
}
|
|
}
|
|
|
|
export const buildTimePhotoLoader = new BuildTimePhotoLoader()
|