first commit
This commit is contained in:
commit
7c46ee6909
107 changed files with 5563 additions and 0 deletions
69
frontend/src/pages/projects/[page].astro
Normal file
69
frontend/src/pages/projects/[page].astro
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
---
|
||||
// Страницы проектов генерируются при запросе (не при сборке)
|
||||
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<Project> = {
|
||||
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. Примеры моих работ и кейсов.`;
|
||||
---
|
||||
|
||||
<Layout title={title} description={description} canonicalLink={`/projects/${currentPage}`}>
|
||||
<section class="relative z-20 max-w-4xl mx-auto my-12 px-7 lg:px-0">
|
||||
<PageHeading
|
||||
title="Портфолио моих лучших веб-проектов и работ"
|
||||
description="Здесь собраны все проекты, над которыми я работал."
|
||||
/>
|
||||
|
||||
<ProjectGrid projects={page.data} />
|
||||
<Pagination page={page} client:load />
|
||||
</section>
|
||||
</Layout>
|
||||
Loading…
Add table
Add a link
Reference in a new issue