This commit is contained in:
Janis
2023-02-10 14:48:59 +01:00
parent 730f33879b
commit 29c97e2c90
10 changed files with 530 additions and 64 deletions

View File

@@ -6,9 +6,9 @@ import { Prisma } from '@prisma/client';
type SearchArticle = Prisma.ArticleGetPayload<{ select: { title: true, name: true } }>
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
let query: string = req.query.q?.toString() ?? "";
let query: string = req.query?.q?.toString() ?? "";
query = formatTextToUrlName(query)
if (query.length > 0) {
if (query?.length > 0) {
await prisma.article.findMany({
select: { title: true, name: true },
take: 5,