mirror of
https://github.com/lucide-icons/lucide.git
synced 2026-11-10 13:18:25 +00:00
Updated the search api
This commit is contained in:
@@ -10,6 +10,7 @@ import { resourcesSidebar } from './sidebar/resources';
|
||||
import llmstxt from 'vitepress-plugin-llms';
|
||||
import { transformPageData } from './transformPageData';
|
||||
import getHeadConfig from './getHeadConfig';
|
||||
import { ALGOLIA_APP_ID, ALGOLIA_SEARCH_API_KEY } from './theme/utils/algolia';
|
||||
|
||||
const defaultSandpackCSS = await readFile(
|
||||
fileURLToPath(new URL('./theme/sandpack-default.css', import.meta.url)),
|
||||
@@ -134,8 +135,8 @@ export default defineConfig({
|
||||
search: {
|
||||
provider: 'algolia',
|
||||
options: {
|
||||
appId: 'R7KKMCPXOB',
|
||||
apiKey: 'dd3101054267d35fb28f49c42715f1aa',
|
||||
appId: ALGOLIA_APP_ID,
|
||||
apiKey: ALGOLIA_SEARCH_API_KEY,
|
||||
indexName: 'lucide',
|
||||
},
|
||||
},
|
||||
|
||||
@@ -15,6 +15,11 @@ export default async function getStructuredData(iconName: string, pageData: Page
|
||||
|
||||
const awaitingRelease = Boolean(params.awaitingRelease);
|
||||
|
||||
// Aliases come through either as plain names or as `{ name, deprecated, ... }` objects.
|
||||
const aliases: string[] = (params.aliases ?? [])
|
||||
.map((alias: string | { name?: string }) => (typeof alias === 'string' ? alias : alias?.name))
|
||||
.filter((alias?: string): alias is string => Boolean(alias));
|
||||
|
||||
return {
|
||||
'@context': 'https://schema.org',
|
||||
'@type': 'WebPage',
|
||||
@@ -39,6 +44,7 @@ export default async function getStructuredData(iconName: string, pageData: Page
|
||||
'@type': 'ImageObject',
|
||||
'@id': `${url}#icon`,
|
||||
name: iconName,
|
||||
...(aliases.length ? { alternateName: aliases } : {}),
|
||||
// TODO: Add support for description extraction from icon metadata
|
||||
// description: 'An ...SVG icon from the Lucide icon set.',
|
||||
// `/api/icons/<name>` only renders core icons, a lab name would 404 there.
|
||||
|
||||
@@ -1,23 +1,7 @@
|
||||
import type { LiteClient } from 'algoliasearch/lite';
|
||||
|
||||
/**
|
||||
* Public search credentials. The search-only key is meant to be shipped in the client
|
||||
* bundle, so local dev, forks and preview deployments search the production index
|
||||
* without any configuration. `VITE_ALGOLIA_*` env vars override these defaults.
|
||||
*
|
||||
* The index itself is populated by the Algolia crawler; nothing in the docs writes to it.
|
||||
*/
|
||||
const DEFAULTS = {
|
||||
appId: 'R7KKMCPXOB',
|
||||
searchApiKey: 'dd3101054267d35fb28f49c42715f1aa',
|
||||
indexName: 'icons',
|
||||
};
|
||||
|
||||
export const ALGOLIA_APP_ID = import.meta.env.VITE_ALGOLIA_APP_ID || DEFAULTS.appId;
|
||||
export const ALGOLIA_SEARCH_API_KEY =
|
||||
import.meta.env.VITE_ALGOLIA_SEARCH_API_KEY || DEFAULTS.searchApiKey;
|
||||
export const ALGOLIA_INDEX_NAME = import.meta.env.VITE_ALGOLIA_INDEX_NAME || DEFAULTS.indexName;
|
||||
|
||||
export const ALGOLIA_APP_ID = 'R7KKMCPXOB';
|
||||
export const ALGOLIA_SEARCH_API_KEY = 'dd3101054267d35fb28f49c42715f1aa'; // public key.
|
||||
/**
|
||||
* The index caps retrievable hits at 1000 per query (`paginationLimitedTo`),
|
||||
* so a single page of this size is the most we can ever get back.
|
||||
@@ -67,7 +51,7 @@ export async function searchIconIds(query: string): Promise<string[]> {
|
||||
} = await client.searchForHits<{ objectID: string }>({
|
||||
requests: [
|
||||
{
|
||||
indexName: ALGOLIA_INDEX_NAME,
|
||||
indexName: 'icons',
|
||||
query,
|
||||
hitsPerPage: HITS_PER_PAGE,
|
||||
attributesToRetrieve: ['objectID'],
|
||||
|
||||
Reference in New Issue
Block a user