last added fix

This commit is contained in:
felipe 2025-04-03 13:59:27 -03:00
parent e06b38d61d
commit 42c543f558
2 changed files with 5 additions and 5 deletions

View file

@ -50,7 +50,7 @@ const lastAlbums = await prismaClient.albums.findMany({
} }
</div> </div>
<div class='flex gap-x-2 py-4'> <div class='flex gap-x-2 py-4'>
<a class='bg-dark uppercase rounded-md text-2xl p-1.5 font-semibold w-full'>{m.moreLastAdded}</a> <a href="/last-added" class='bg-dark uppercase rounded-md text-2xl p-1.5 font-semibold w-full'>{m.moreLastAdded}</a>
</div> </div>
</div> </div>
<Sidebar /> <Sidebar />

View file

@ -5,18 +5,18 @@ import { AlbumStatus } from '@prisma/client'
import PaginatedAlbumList from 'layouts/PaginatedAlbumList.astro' import PaginatedAlbumList from 'layouts/PaginatedAlbumList.astro'
const page = Math.min(1, parseInt(Astro.params.page ?? '1')) const page = Math.max(1, parseInt(Astro.params.page ?? '1'));
const take = 40 const take = 50
const limitMD = 12 const limitMD = 12
const limitXS = 5 const limitXS = 5
const albums = await prismaClient.albums.findMany({ const albums = await prismaClient.albums.findMany({
where: { status: AlbumStatus.SHOW }, where: { status: AlbumStatus.SHOW },
select: { id: true, title: true }, select: { id: true, title: true, publishedAt: true },
take, take,
skip: take * (page - 1), skip: take * (page - 1),
orderBy: { publishedAt: 'desc' } orderBy: { publishedAt: 'desc' }
}) });
const count = await prismaClient.albums.count({ where: { status: AlbumStatus.SHOW } }) const count = await prismaClient.albums.count({ where: { status: AlbumStatus.SHOW } })
const fullPageList = [...Array(Math.ceil(count / take))].map((v, i) => i + 1) const fullPageList = [...Array(Math.ceil(count / take))].map((v, i) => i + 1)