refactor: ProjectsSection — use shared buildFileUrl, pass url prop, switch to stacked layout

This commit is contained in:
Ilia Mashkov
2026-05-18 20:46:02 +03:00
parent ac9ee0eb4e
commit 06e39b58c6
@@ -1,19 +1,7 @@
import { ProjectCard } from '$entities/project'; import { ProjectCard } from '$entities/project';
import type { ProjectRecord } from '$shared/api'; import type { ProjectRecord } from '$shared/api';
import { getCollection } from '$shared/api'; import { getCollection } from '$shared/api';
import { buildFileUrl } from '$shared/lib';
/** Base URL for PocketBase file storage */
const PB_URL = process.env.NEXT_PUBLIC_PB_URL || 'http://127.0.0.1:8090';
/**
* Builds a PocketBase file URL for a project image.
*/
function buildImageUrl(project: ProjectRecord): string | undefined {
if (!project.image) {
return undefined;
}
return `${PB_URL}/api/files/${project.collectionId}/${project.id}/${project.image}`;
}
/** /**
* Projects section component. * Projects section component.
@@ -25,7 +13,7 @@ export default async function ProjectsSection() {
}); });
return ( return (
<div className="grid grid-cols-1 md:grid-cols-2 gap-6 max-w-section"> <div className="space-y-6 max-w-section">
{items.map((project) => ( {items.map((project) => (
<ProjectCard <ProjectCard
key={project.id} key={project.id}
@@ -33,7 +21,8 @@ export default async function ProjectsSection() {
year={project.year} year={project.year}
description={project.description} description={project.description}
tags={project.stack} tags={project.stack}
imageUrl={buildImageUrl(project)} url={project.url}
imageUrl={project.image ? buildFileUrl(project.collectionId, project.id, project.image) : undefined}
/> />
))} ))}
</div> </div>