mirror of
https://github.com/jorgev259/soc_site-astro.git
synced 2025-06-29 07:57:41 +00:00
This commit is contained in:
parent
87b2fc0796
commit
1cd11fea2b
2 changed files with 7 additions and 7 deletions
|
|
@ -19,17 +19,17 @@ let { page } = Astro.props
|
||||||
if (page < 1) page = 1
|
if (page < 1) page = 1
|
||||||
|
|
||||||
const queryString = query
|
const queryString = query
|
||||||
.toLowerCase()
|
.trim()
|
||||||
.split('_')
|
.split(/[\s_\-:]+/)
|
||||||
.map((w) => `+${w}`)
|
|
||||||
.join(' ')
|
.join(' ')
|
||||||
|
|
||||||
const findQuery: Prisma.albumsFindManyArgs = {
|
const findQuery: Prisma.albumsFindManyArgs = {
|
||||||
select: { title: true, releaseDate: true, id: true },
|
select: { title: true, releaseDate: true, id: true },
|
||||||
where: {
|
where: {
|
||||||
OR: [{ title: { search: queryString } }, { subTitle: { search: queryString } }]
|
OR: [{ title: { search: queryString } }, { subTitle: { search: queryString } }]
|
||||||
},
|
},
|
||||||
orderBy: {
|
orderBy: {
|
||||||
_relevance: { fields: ['title', 'subTitle'], sort: 'desc', search: query.toLowerCase() }
|
_relevance: { fields: ['title', 'subTitle'], sort: 'desc', search: queryString }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const countQuery: Prisma.albumsCountArgs<DefaultArgs> = {
|
const countQuery: Prisma.albumsCountArgs<DefaultArgs> = {
|
||||||
|
|
@ -76,6 +76,6 @@ const end = Math.min(page * take, count)
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class='text-xl flex gap-x-2'>
|
<div class='flex gap-x-2'>
|
||||||
<SearchNav query={query} count={count} take={take} page={page} />
|
<SearchNav query={query} count={count} take={take} page={page} />
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -14,9 +14,9 @@ const pageCount = Math.ceil(count / take)
|
||||||
pageCount > 1
|
pageCount > 1
|
||||||
? Array.from({ length: pageCount }, (_, i) =>
|
? Array.from({ length: pageCount }, (_, i) =>
|
||||||
page === i + 1 ? (
|
page === i + 1 ? (
|
||||||
<span class='bg-gray rounded px-2 cursor-pointer'>{i + 1}</span>
|
<span class='text-xl bg-gray rounded px-2 cursor-pointer'>{i + 1}</span>
|
||||||
) : (
|
) : (
|
||||||
<a class='bg-gray/50 rounded px-2' href={`/search?q=${query}&page=${i + 1}`}>
|
<a class='text-xl bg-gray/50 rounded px-2' href={`/search?q=${query}&page=${i + 1}`}>
|
||||||
{i + 1}
|
{i + 1}
|
||||||
</a>
|
</a>
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue