Default theme docsearch দিয়ে Algolia DocSearch এবং search দিয়ে custom search component সমর্থন করে, যার মধ্যে @sveltepress/meilisearch-ও আছে।

Algolia DocSearch

Navbar-এ Algolia DocSearch সক্রিয় করতে defaultTheme-এ docsearch config object দিন।

appId, apiKey এবং indexName আবশ্যিক। অন্য সব DocSearch option-ও ব্যবহার করা যায়।

vite.config.(js|ts)
import { const defaultTheme: ThemeDefaultdefaultTheme } from '@sveltepress/theme-default'
import { const sveltepress: (options?: SveltepressVitePluginOptions) => PluginOptionsveltepress } from '@sveltepress/vite'
import { function defineConfig(config: UserConfig): UserConfig (+5 overloads)

Type helper to make it easier to use vite.config.ts accepts a direct

UserConfig

object, or a function that returns it. The function receives a

ConfigEnv

object.

defineConfig
} from 'vite'
export default function defineConfig(config: UserConfig): UserConfig (+5 overloads)

Type helper to make it easier to use vite.config.ts accepts a direct

UserConfig

object, or a function that returns it. The function receives a

ConfigEnv

object.

defineConfig
({
UserConfig.plugins?: PluginOption[] | undefined

Array of vite plugins to use.

plugins
: [
function sveltepress(options?: SveltepressVitePluginOptions): PluginOptionsveltepress({ SveltepressVitePluginOptions.theme?: ResolvedTheme | undefinedtheme: function defaultTheme(themeOptions?: DefaultThemeOptions | undefined): ResolvedThemedefaultTheme({ DefaultThemeOptions.docsearch?: Omit<DocSearchProps, "theme" | "container"> | undefineddocsearch: { appId: string

Algolia application id used by the search client.

appId
: 'YOUR_APP_ID',
apiKey: string

Public api key with search permissions for the index.

apiKey
: 'YOUR_SEARCH_API_KEY',
indexName?: string | undefined

Name of the algolia index to query.

@deprecatedindexName will be removed in a future version. Please use indices property going forward.
indexName
: 'YOUR_INDEX_NAME',
}, }), }), ], })
ts
DocSearch-এর জন্য আবেদন

Open-source documentation site-এর জন্য DocSearch বিনামূল্যে পাওয়া যায়। docsearch.algolia.com-এ আবেদন করুন।

Meilisearch

@sveltepress/meilisearch হলো supported Meilisearch search component। প্রথমে package-টি install করুন:

npm install --save @sveltepress/meilisearch
sh
yarn add @sveltepress/meilisearch
sh
pnpm install @sveltepress/meilisearch
sh
bun add @sveltepress/meilisearch
sh

Meilisearch connection setting দেওয়ার জন্য একটি wrapper component তৈরি করুন:

src/lib/MeilisearchSearch.svelte
<script lang="ts">
  import 
type Search = SvelteComponent<Record<string, any>, any, any>
const Search: LegacyComponentType
Search
from '@sveltepress/meilisearch/Search.svelte'
</script> <const Search: LegacyComponentTypeSearch host: stringhost="https://search.example.com" apiKey: stringapiKey="YOUR_SEARCH_ONLY_KEY" indexName: stringindexName="docs" />
svelte

তারপর default theme-এর custom-search hook-এ wrapper path দিন:

vite.config.(js|ts)
import { const defaultTheme: ThemeDefaultdefaultTheme } from '@sveltepress/theme-default'

function defaultTheme(themeOptions?: DefaultThemeOptions | undefined): ResolvedThemedefaultTheme({
  DefaultThemeOptions.search?: string | boolean | Component<{}, {}, string> | undefinedsearch: '/src/lib/MeilisearchSearch.svelte',
})
ts

Component-টি আগে থেকে তৈরি Meilisearch index query করে; এটি index তৈরি করে না। প্রতিটি record-এ id, title, content, এবং url অথবা path থাকা উচিত। Browser code-এ search-only API key ব্যবহার করুন।

Known production build bug

Custom-search API এবং @sveltepress/meilisearch component supported, এবং উপরের source-path setup development-এ কাজ করে। তবে বর্তমান default-theme runtime .svelte path-টিকে browser import হিসেবে রেখে দেয়, তাই static production build wrapper-টি bundle করে না। সরাসরি component object দিলেও theme-option serialization সেটি বাদ দেয়। এটি default-theme bundling-এর production build bug, M Search support না থাকার প্রমাণ নয়। Runtime integration fix না হওয়া পর্যন্ত production deployment যাচাই করুন।

অন্য search provider-এর জন্য একই search hook-এ নিজস্ব Svelte wrapper দিন। search ও docsearch দুটোই configure করলে search অগ্রাধিকার পায়।