From 9f3e18ae0d56b24b4dedccd57b0c321cbc51c08c Mon Sep 17 00:00:00 2001 From: Arthur DANJOU Date: Tue, 3 Sep 2024 20:14:31 +0200 Subject: [PATCH] Add icons to search query --- nuxt.config.ts | 4 +++- server/api/icons/search.get.ts | 5 +++-- types/types.ts | 7 +++++++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/nuxt.config.ts b/nuxt.config.ts index 5af9852..77ab09a 100644 --- a/nuxt.config.ts +++ b/nuxt.config.ts @@ -1,3 +1,5 @@ +import { IconsCollection } from './types/types' + export default defineNuxtConfig({ future: { compatibilityVersion: 4 }, @@ -43,7 +45,7 @@ export default defineNuxtConfig({ // Nuxt Icon icon: { - serverBundle: ['ph', 'heroicons', 'vscode-icons', 'simple-icons'], + serverBundle: IconsCollection, }, // Nuxt Color Mode diff --git a/server/api/icons/search.get.ts b/server/api/icons/search.get.ts index 7ab2167..31adfc4 100644 --- a/server/api/icons/search.get.ts +++ b/server/api/icons/search.get.ts @@ -1,11 +1,12 @@ +import { IconsCollection } from '~~/types/types' + export default defineEventHandler(async (event) => { - const collections = ['ph', 'heroicons'] const { query } = getQuery(event) const response = await $fetch('https://api.iconify.design/search', { params: { query, - prefixes: collections.join(','), + prefixes: IconsCollection.join(','), }, }) diff --git a/types/types.ts b/types/types.ts index 84a38f8..5f0455b 100644 --- a/types/types.ts +++ b/types/types.ts @@ -4,6 +4,13 @@ export const COLORS = ['gray', 'slate', 'zinc', 'neutral', 'stone', 'red', 'oran export const Subscription = ['free', 'paid'] as const +export const IconsCollection = [ + 'ph', + 'heroicons', + 'vscode-icons', + 'simple-icons', +] as const + // Category export const CreateCategorySchema = z.object({ name: z.string().min(4).max(20),