{"id":16228490,"url":"https://github.com/pyoner/svelte-search-engine","last_synced_at":"2026-02-06T03:32:40.227Z","repository":{"id":252754313,"uuid":"841339033","full_name":"pyoner/svelte-search-engine","owner":"pyoner","description":"A customizable search engine component library for Svelte applications, powered by Google's Programmable Search Engine.","archived":false,"fork":false,"pushed_at":"2024-08-20T09:42:47.000Z","size":128,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-24T14:27:03.194Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pyoner.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-08-12T07:56:51.000Z","updated_at":"2024-08-22T14:28:17.000Z","dependencies_parsed_at":"2024-08-18T07:41:24.778Z","dependency_job_id":"d614a86b-4b42-4340-894f-b8efbc446c65","html_url":"https://github.com/pyoner/svelte-search-engine","commit_stats":null,"previous_names":["pyoner/svelte-cse","pyoner/svelte-search-engine"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/pyoner/svelte-search-engine","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyoner%2Fsvelte-search-engine","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyoner%2Fsvelte-search-engine/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyoner%2Fsvelte-search-engine/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyoner%2Fsvelte-search-engine/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pyoner","download_url":"https://codeload.github.com/pyoner/svelte-search-engine/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyoner%2Fsvelte-search-engine/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29148177,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-06T02:39:25.012Z","status":"ssl_error","status_checked_at":"2026-02-06T02:37:22.784Z","response_time":59,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-10T12:55:27.647Z","updated_at":"2026-02-06T03:32:40.211Z","avatar_url":"https://github.com/pyoner.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Svelte Search Engine\n\nA customizable search engine component library for Svelte applications, powered by Google's Programmable Search Engine.\n\n## Features\n\n- Easy integration with Google's Custom Search Engine\n- Customizable search components (Search, SearchBox, SearchResults)\n- Support for both web and image search\n- TypeScript support\n- Reactive stores for search state management\n- Customizable UI components for search results\n\n## Installation\n\n```bash\nnpm install svelte-search-engine\n```\n\n\n## Usage\n\n1. Set up a Google Programmable Search Engine and obtain your CX ID.\n\n2. Add your CX ID to your environment variables:\n\n```env\nPUBLIC_CSE_CX=your_cx_id_here\n```\n\n3. Import and use the components in your Svelte app:\n\n```svelte\n\u003cscript\u003e\n  import { Engine, Search } from 'svelte-search-engine';\n  import { PUBLIC_CSE_CX } from '$env/static/public';\n\u003c/script\u003e\n\n\u003cEngine cx={PUBLIC_CSE_CX}\u003e\n  \u003cSearch\n    attributes={{\n      gname: 'web',\n      enableImageSearch: false\n    }}\n  /\u003e\n\u003c/Engine\u003e\n```\n\n\n## Components\n\n### Engine\n\nThe `Engine` component initializes the Google Custom Search Engine script and provides the context for other search components.\n\n```svelte\n\u003cEngine cx={YOUR_CX_ID}\u003e\n  \u003c!-- Other search components go here --\u003e\n\u003c/Engine\u003e\n```\n\n\n### Search\n\nThe `Search` component renders a complete search interface, including the search box and results.\n\n```svelte\n\u003cSearch\n  attributes={{\n    gname: 'web',\n    enableImageSearch: false\n  }}\n  components={{ web: CustomResultsComponent }}\n/\u003e\n```\n\n\n### SearchBox\n\nThe `SearchBox` component renders only the search input field.\n\n```svelte\n\u003cSearchBox\n  attributes={{\n    gname: 'mySearchBox'\n  }}\n/\u003e\n```\n\n\n### SearchResults\n\nThe `SearchResults` component renders only the search results.\n\n```svelte\n\u003cSearchResults\n  attributes={{\n    gname: 'mySearchResults'\n  }}\n  components={{ web: CustomResultsComponent }}\n/\u003e\n```\n\n\n## Customization\n\nYou can customize the appearance and behavior of the search components by passing `attributes` and `components` props.\nFor a full list of available attributes, refer to the `ComponentAttributes` interface in the source code:\n\n```typescript\nexport interface ComponentAttributes {\n\t/** The name of the Search Element object. */\n\tgname?: Gname;\n\n\t/** Whether to execute a search by the query embedded in the URL of the page that's loading. */\n\tautoSearchOnLoad?: boolean;\n\n\t/** Enables history management for the browser Back and Forward buttons. */\n\tenableHistory?: boolean;\n\n\t/** The query parameter name embedded in the URL. */\n\tqueryParameterName?: string;\n\n\t/** The URL of the results page. */\n\tresultsUrl?: string;\n\n\t/** Whether the results page opens in a new window. */\n\tnewWindow?: boolean;\n\n\t/** Allows invalid traffic-only cookies and local storage based on consent status. */\n\tivt?: boolean;\n\n\t/** Specifies whether the mobile layout styles should be used for mobile devices. */\n\tmobileLayout?: 'enabled' | 'disabled' | 'forced';\n\n\t/** Enables autocomplete if configured in the control panel. */\n\tenableAutoComplete?: boolean;\n\n\t/** The maximum number of autocompletions to display. */\n\tautoCompleteMaxCompletions?: number;\n\n\t/** The maximum number of promotions to display in autocomplete. */\n\tautoCompleteMaxPromotions?: number;\n\n\t/** Comma-separated list of languages for which autocomplete should be enabled. */\n\tautoCompleteValidLanguages?: string;\n\n\t/** Specifies the default refinement label to display. */\n\tdefaultToRefinement?: string;\n\n\t/** Specifies the style of refinements, either tab or link. */\n\trefinementStyle?: 'tab' | 'link';\n\n\t/** Enables image search if configured in the control panel. */\n\tenableImageSearch?: boolean;\n\n\t/** Specifies if the search results page will display image search results by default. */\n\tdefaultToImageSearch?: boolean;\n\n\t/** Specifies the layout of the image search results page. */\n\timageSearchLayout?: 'classic' | 'column' | 'popup';\n\n\t/** Specifies the maximum size of the search results set for image search. */\n\timageSearchResultSetSize?: number | string;\n\n\t/** Restricts results to files of a specified extension. */\n\timage_as_filetype?: 'jpg' | 'gif' | 'png' | 'bmp' | 'svg' | 'webp' | 'ico' | 'raw';\n\n\t/** Filters search results using Logical OR. */\n\timage_as_oq?: string;\n\n\t/** Filters based on licensing. */\n\timage_as_rights?:\n\t\t| 'cc_publicdomain'\n\t\t| 'cc_attribute'\n\t\t| 'cc_sharealike'\n\t\t| 'cc_noncommercial'\n\t\t| 'cc_nonderived';\n\n\t/** Restrict results to pages from a specific site. */\n\timage_as_sitesearch?: string;\n\n\t/** Restricts search to black and white, grayscale, or color images. */\n\timage_colortype?: 'mono' | 'gray' | 'color';\n\n\t/** Restricts search results to documents originating in a particular country. */\n\timage_cr?: string;\n\n\t/** Restricts search to images of a specific dominant color. */\n\timage_dominantcolor?:\n\t\t| 'red'\n\t\t| 'orange'\n\t\t| 'yellow'\n\t\t| 'green'\n\t\t| 'teal'\n\t\t| 'blue'\n\t\t| 'purple'\n\t\t| 'pink'\n\t\t| 'white'\n\t\t| 'gray'\n\t\t| 'black'\n\t\t| 'brown';\n\n\t/** Enables or disables automatic filtering of search results. */\n\timage_filter?: '0' | '1';\n\n\t/** Boosts search results whose country of origin matches the parameter value. */\n\timage_gl?: string;\n\n\t/** Specifies the size of images returned in search results. */\n\timage_size?: 'icon' | 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge' | 'huge';\n\n\t/** Sorts results using either date or other structured content. */\n\timage_sort_by?: '' | 'date';\n\n\t/** Restricts search to images of a specific type. */\n\timage_type?: 'clipart' | 'face' | 'lineart' | 'stock' | 'photo' | 'animated';\n\n\t/** Disables web search if true. */\n\tdisableWebSearch?: boolean;\n\n\t/** Extra terms added to search query using logical OR. */\n\twebSearchQueryAddition?: string;\n\n\t/** The maximum size of the web search results set. */\n\twebSearchResultSetSize?: number | string;\n\n\t/** Specifies if SafeSearch is enabled for web search results. */\n\twebSearchSafesearch?: 'off' | 'active';\n\n\t/** Restricts results to files of a specified extension. */\n\tas_filetype?: string;\n\n\t/** Filters search results using Logical OR. */\n\tas_oq?: string;\n\n\t/** Filters based on licensing. */\n\tas_rights?:\n\t\t| 'cc_publicdomain'\n\t\t| 'cc_attribute'\n\t\t| 'cc_sharealike'\n\t\t| 'cc_noncommercial'\n\t\t| 'cc_nonderived';\n\n\t/** Restrict results to pages from a specific site. */\n\tas_sitesearch?: string;\n\n\t/** Restricts search results to documents originating in a particular country. */\n\tcr?: string;\n\n\t/** Enables or disables automatic filtering of search results. */\n\tfilter?: '0' | '1';\n\n\t/** Boosts search results whose country of origin matches the parameter value. */\n\tgl?: string;\n\n\t/** Restricts search results to documents written in a particular language. */\n\tlr?: string;\n\n\t/** Sort results using either date or other structured content. */\n\tsort_by?: string;\n\n\t/** Enables the sorting of results by relevance, date, or label. */\n\tenableOrderBy?: boolean;\n\n\t/** Sets the link target. Default: _blank */\n\tlinkTarget?: '_blank' | '_self' | '_parent' | '_top';\n\n\t/** Specifies the default text to display when no results match the query. */\n\tnoResultsString?: string;\n\n\t/** The maximum size of the results set. */\n\tresultSetSize?: number | string;\n\n\t/** Specifies if SafeSearch is enabled for both web and image search. */\n\tsafeSearch?: 'off' | 'active';\n}\n```\n\n\n## Stores\n\nThe library provides reactive stores for managing search state:\n\n```typescript\nimport { init, starting, ready, rendered } from 'svelte-search-engine';\n\ninit.subscribe(value =\u003e console.log('Initialization state:', value));\nstarting.subscribe(value =\u003e console.log('Search starting:', value));\nready.subscribe(value =\u003e console.log('Search results ready:', value));\nrendered.subscribe(value =\u003e console.log('Search results rendered:', value));\n```\n\n## Custom Results Component\n\nYou can create a custom results component to display search results:\n\n```svelte\n\u003cscript lang=\"ts\"\u003e\n  import type { Promotion, Result } from 'svelte-search-engine';\n\n  export let promos: Promotion[] | undefined;\n  export let results: Result[];\n\u003c/script\u003e\n\n\u003c!-- Your custom results layout here --\u003e\n```\n\nThen use it in the `Search` or `SearchResults` component:\n\n```svelte\n\u003cSearch\n  attributes={{ gname: 'web' }}\n  components={{ web: YourCustomResultsComponent }}\n/\u003e\n```\n\n## License\n\nMIT\n\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpyoner%2Fsvelte-search-engine","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpyoner%2Fsvelte-search-engine","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpyoner%2Fsvelte-search-engine/lists"}