Skip to content

Commit

Permalink
more simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
martinhj committed Jan 23, 2024
1 parent a070760 commit 358bdca
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 25 deletions.
26 changes: 24 additions & 2 deletions frontend/pages/api/search.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
// Utils
import getSearchResults from '../../src/utils/getSearchResults';
import groq from 'groq';
import { clientGROQ } from '../../groq/client';

const getSearchResults = async ({ query, language }) => {
const currentQuery = String(query || '');

const groqQuery = groq`
{
"all": *[
_type in ["Activity", "Article", "Page", "Place", "Region", "Service", "Provider", "ThingsToDoPage", "DayTrip"]
&& expired != true
] | score(boost(_type == 'Place', 2)) [0...10] { _id },
}
`;

const results = await clientGROQ.fetch(groqQuery, {
query: currentQuery,
categoryId: '',
language,
fallback: 'en',
});

return { results, currentQuery };
};

export default async function handler(req, res) {
// Disallow non-GET methods
Expand Down
23 changes: 0 additions & 23 deletions frontend/src/utils/getSearchResults.js

This file was deleted.

0 comments on commit 358bdca

Please sign in to comment.