2024-07-26 12:45:20 +02:00
|
|
|
import type { ProjectType } from '@/types/project'
|
2024-02-06 00:20:48 +01:00
|
|
|
import { getProjectImages } from './images'
|
|
|
|
import { markdownToHtml } from './markdown'
|
2024-02-04 23:09:00 +01:00
|
|
|
|
|
|
|
export async function transformProject(
|
|
|
|
projectsOriginal: ProjectType[],
|
|
|
|
slug: string
|
|
|
|
) {
|
|
|
|
const project = projectsOriginal.find((item) => item.slug === slug)
|
|
|
|
if (!project) return
|
|
|
|
|
|
|
|
// enhance data with additional fields
|
|
|
|
const descriptionHtml = await markdownToHtml(project.description)
|
|
|
|
project.descriptionHtml = descriptionHtml
|
|
|
|
|
|
|
|
const images = await getProjectImages(slug)
|
|
|
|
project.images = images
|
|
|
|
|
|
|
|
return project
|
|
|
|
}
|