import { SearchBaseClass } from "../../helpers/search"; export interface PexelsResult { url: string; photographer: string; src: { original: string; large2x: string; tiny: string; }; } export default class Pexels extends SearchBaseClass { constructor(apiKey: string) { super({ apiKey, name: "pexels", icon: ``, color: "#05a081", poweredByUrl: "https://pexels.com", popularEndpoint: (apiKey: string) => `https://api.pexels.com/v1/curated?per_page=9&page=1`, searchEndpoint: (apiKey: string, query: string) => `https://api.pexels.com/v1/search?query=${encodeURIComponent( query )}&per_page=12&page=1`, getButton: (image: PexelsResult) => `
${image.photographer}
`, getSearchResults: (response: { photos: PexelsResult[] }) => response.photos, getPopularResults: (response: { photos: PexelsResult[] }) => response.photos, fetchSettings: (apiKey: string) => ({ headers: { Authorization: apiKey, }, }), }); } }