PluginProbe
Extendify / 3.2.1
Extendify v3.2.1
3.2.1 3.2.0 3.1.6 3.1.5 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.6 3.0.5 3.0.4 trunk 0.1.0 0.10.0 0.10.1 0.10.2 0.11.0 0.11.1 0.2.0 0.3.0 0.3.1 0.4.0 0.5.0 0.6.0 All 127 releases
extendify / src / Shared / lib / vibes.js

vibes.js in Extendify 3.2.1, at src/Shared/lib/vibes.js

24 lines 753 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { AI_HOST } from '@constants';
2
3 // The whole set is a third of a megabyte, so callers ask for what they show.
4 export const getVibes = async (query = '') => {
5 const url = new URL(`${AI_HOST}/api/vibes`);
6 if (query) url.searchParams.set('vibes', query);
7
8 const response = await fetch(url, {
9 method: 'GET',
10 headers: { 'Content-Type': 'application/json' },
11 });
12
13 if (!response.ok) throw new Error('Bad response from server');
14
15 const { vibes } = await response.json();
16 return Array.isArray(vibes) ? vibes : [];
17 };
18
19 export const vibesBySlug = (vibes) =>
20 Object.fromEntries((vibes ?? []).map((vibe) => [vibe.slug, vibe]));
21
22 export const vibeCssBySlug = (vibes) =>
23 Object.fromEntries((vibes ?? []).map(({ slug, css }) => [slug, css ?? '']));
24