homepage/src/pages/api/searchSuggestion.js
Flo2410 cc73839874
Added search suggestions to the quick launch menu.
If this feture and the search feature of the `quicklaunch` are turned on, up to *four* search suggestions will be shown as results.
2024-01-26 21:57:20 +00:00

15 lines
529 B
JavaScript

import { searchProviders } from "components/widgets/search/search";
import cachedFetch from "utils/proxy/cached-fetch";
export default async function handler(req, res) {
const { query, providerName } = req.query;
const provider = Object.values(searchProviders).find(({ name }) => name === providerName);
if (!provider.suggestionUrl) {
return res.json([query, []]); // Responde with the same array format but with no suggestions.
}
return res.send(await cachedFetch(`${provider.suggestionUrl}${query}`, 5));
}