--- // Страницы проектов генерируются при запросе (не при сборке) export const prerender = false; import type { Page } from 'astro'; import PageHeading from '@components/base/PageHeading.astro'; import ProjectGrid from '@components/projects/ProjectGrid.astro'; import Layout from '@layouts/Layout.astro'; import Pagination from '@components/base/Pagination.tsx'; import { pb } from '@lib/pocketbase'; import type { Project } from '@globalInterfaces'; // Получаем номер страницы из параметров const { page: pageNumber } = Astro.params; const currentPage = Number(pageNumber) || 1; const perPage = 6; // Получаем проекты из PocketBase для конкретной страницы const result = await pb.collection('projects').getList(currentPage, perPage, { sort: '-order,-created', requestKey: 'projects_list' }); // Маппинг для списка const projects = result.items.map((item) => ({ id: item.id, collectionId: item.collectionId, title: item.name, description: item.description, short_description: item.short_description, long_description: item.long_description, stack: item.stack || [], github_link: item.github, demo_link: item.url_site, image: `${import.meta.env.PUBLIC_POCKETBASE_URL}/api/files/projects/${item.id}/${item.image}`, alt_text: item.alt_text, order: item.order || 0, isActive: item.isActive })); // Создаем объект page вручную const page: Page = { data: projects, firstItem: result.page > 1 ? (result.page - 1) * perPage + 1 : 1, lastItem: Math.min(result.page * perPage, result.totalItems), totalPages: result.totalPages, currentPage: result.page, lastPage: result.totalPages, url: { prev: result.page > 1 ? (result.page > 2 ? `/projects/${result.page - 1}` : '/projects') : undefined, next: result.page < result.totalPages ? `/projects/${result.page + 1}` : undefined, } }; const title = `Портфолио проектов (Страница ${page.currentPage}) | Redi`; const description = `Страница ${page.currentPage} из ${page.totalPages} с проектами в портфолио веб-разработчика Redi. Примеры моих работ и кейсов.`; ---