1 "use client"
2
3 import React from "react"
4 import { usePageLoading, SearchProvider as UiSearchProvider } from "docs-ui"
5 import { config } from "../config"
6 import basePathUrl from "../utils/base-path-url"
7
8 type SearchProviderProps = {
9 children: React.ReactNode
10 }
11
12 const SearchProvider = ({ children }: SearchProviderProps) => {
13 const { isLoading } = usePageLoading()
14 return (
15 <UiSearchProvider
16 algolia={{
17 appId: process.env.NEXT_PUBLIC_ALGOLIA_APP_ID || "temp",
18 apiKey: process.env.NEXT_PUBLIC_ALGOLIA_API_KEY || "temp",
19 mainIndexName: process.env.NEXT_PUBLIC_API_ALGOLIA_INDEX_NAME || "temp",
20 }}
21 indices={[
22 {
23 value: process.env.NEXT_PUBLIC_DOCS_ALGOLIA_INDEX_NAME || "temp",
24 title: "Docs",
25 },
26 {
27 value: process.env.NEXT_PUBLIC_API_ALGOLIA_INDEX_NAME || "temp",
28 title: "Store & Admin API",
29 },
30 ]}
31 defaultIndex={process.env.NEXT_PUBLIC_API_ALGOLIA_INDEX_NAME || "temp"}
32 searchProps={{
33 isLoading,
34 suggestions: [
35 {
36 title: "Getting started? Try one of the following terms.",
37 items: [
38 "Install Medusa with create-medusa-app",
39 "What is an API route?",
40 "What is a Workflow?",
41 ],
42 },
43 {
44 title: "Developing with Medusa",
45 items: [
46 "How to create an API route",
47 "How to create a module",
48 "How to create a data model",
49 "How to create an admin widget",
50 ],
51 },
52 ],
53 checkInternalPattern: new RegExp(
54 `^${config.baseUrl}${basePathUrl(`/(admin|store)`)}`
55 ),
56 }}
57 >
58 {children}
59 </UiSearchProvider>
60 )
61 }
62
63 export default SearchProvider