साइट खोज
डिफ़ॉल्ट रूप से, Starlight साइटों में Pagefind द्वारा संचालित पूर्ण-पाठ खोज शामिल होती है, जो स्थिर साइटों के लिए एक तेज़ और कम बैंडविड्थ वाला खोज उपकरण है।
खोज को सक्षम करने के लिए किसी कॉन्फ़िगरेशन की आवश्यकता नहीं है. अपनी साइट बनाएं और तैनात करें, फिर कंटेंट ढूंढने के लिए साइट हेडर में खोज बार का उपयोग करें।
खोज परिणामों में कंटेंट छिपाएँ
एक पेज को बाहर निकालें
किसी पेज को अपने खोज अनुक्रमणिका से बाहर करने के लिए, पेज के फ्रंटमैटर में pagefind: false
जोड़ें:
---title: खोज से छिपाने के लिए कंटेंटpagefind: false---
किसी पेज का भाग बाहर निकालें
Pagefind data-pagefind-ignore
विशेषता वाले तत्व के अंदर के कंटेंट को अनदेखा कर देगा।
निम्नलिखित उदाहरण में, पहला अनुच्छेद खोज परिणामों में प्रदर्शित होगा, लेकिन <div>
के कंटेंट नहीं दिखाई देंगे:
---title: आंशिक रूप से अनुक्रमित पेज---
यह पाठ खोज के माध्यम से खोजा जा सकेगा.
<div data-pagefind-ignore>
यह पाठ खोज से छिपा दिया जाएगा.
</div>
वैकल्पिक खोज प्रदाता
Algolia DocSearch
यदि आपके पास Algolia’s DocSearch program की पहुंच है और आप Pagefind के बजाय इसका उपयोग करना चाहते हैं, तो आप आधिकारिक Starlight DocSearch प्लगइन का उपयोग कर सकते हैं।
-
@astrojs/starlight-docsearch
इंस्टॉल करें:Terminal window npm install @astrojs/starlight-docsearchTerminal window pnpm add @astrojs/starlight-docsearchTerminal window yarn add @astrojs/starlight-docsearch -
DocSearch को
astro.config.mjs
में अपने Starlightप्लगइन
कॉन्फिगरेशन में जोड़ें और इसे अपना AlgoliaappId
,apiKey
औरindexName
पास करें:astro.config.mjs import { defineConfig } from 'astro/config';import starlight from '@astrojs/starlight';import starlightDocSearch from '@astrojs/starlight-docsearch';export default defineConfig({integrations: [starlight({title: 'DocSearch वाली साइट',plugins: [starlightDocSearch({appId: 'YOUR_APP_ID',apiKey: 'YOUR_SEARCH_API_KEY',indexName: 'YOUR_INDEX_NAME',}),],}),],});
इस अद्यतन कॉन्फ़िगरेशन के साथ, आपकी साइट पर खोज बार अब डिफ़ॉल्ट खोज मोडल के बजाय एक अल्गोलिया मोडल खोलेगा।
DocSearch UI का अनुवाद कैसे करे
DocSearch डिफ़ॉल्ट रूप से केवल अंग्रेज़ी UI स्ट्रिंग्स प्रदान करता है। Starlight की अंतर्निहित अंतर्राष्ट्रीयकरण प्रणाली का उपयोग करके अपनी भाषा के लिए मोडल UI का अनुवाद जोड़ें।
-
src/content/config.ts
में DocSearch schema के साथ Starlight कीi18n
सामग्री संग्रह परिभाषा का विस्तार करें:src/content/config.ts import { defineCollection } from 'astro:content';import { docsSchema, i18nSchema } from '@astrojs/starlight/schema';import { docSearchI18nSchema } from '@astrojs/starlight-docsearch/schema';export const collections = {docs: defineCollection({ schema: docsSchema() }),i18n: defineCollection({type: 'data',schema: i18nSchema({ extend: docSearchI18nSchema() }),}),}; -
अपनी JSON फ़ाइलों में
src/content/i18n/
में अनुवाद जोड़ें।ये DocSearch द्वारा उपयोग किए जाने वाले अंग्रेजी डिफ़ॉल्ट हैं:
src/content/i18n/en.json {"docsearch.searchBox.resetButtonTitle": "Clear the query","docsearch.searchBox.resetButtonAriaLabel": "Clear the query","docsearch.searchBox.cancelButtonText": "Cancel","docsearch.searchBox.cancelButtonAriaLabel": "Cancel","docsearch.startScreen.recentSearchesTitle": "Recent","docsearch.startScreen.noRecentSearchesText": "No recent searches","docsearch.startScreen.saveRecentSearchButtonTitle": "Save this search","docsearch.startScreen.removeRecentSearchButtonTitle": "Remove this search from history","docsearch.startScreen.favoriteSearchesTitle": "Favorite","docsearch.startScreen.removeFavoriteSearchButtonTitle": "Remove this search from favorites","docsearch.errorScreen.titleText": "Unable to fetch results","docsearch.errorScreen.helpText": "You might want to check your network connection.","docsearch.footer.selectText": "to select","docsearch.footer.selectKeyAriaLabel": "Enter key","docsearch.footer.navigateText": "to navigate","docsearch.footer.navigateUpKeyAriaLabel": "Arrow up","docsearch.footer.navigateDownKeyAriaLabel": "Arrow down","docsearch.footer.closeText": "to close","docsearch.footer.closeKeyAriaLabel": "Escape key","docsearch.footer.searchByText": "Search by","docsearch.noResultsScreen.noResultsText": "No results for","docsearch.noResultsScreen.suggestedQueryText": "Try searching for","docsearch.noResultsScreen.reportMissingResultsText": "Believe this query should return results?","docsearch.noResultsScreen.reportMissingResultsLinkText": "Let us know."}