feat: Enable API search (#353)
* enabled search in ref and changed from section -> main so Algolia will index ref content * fix: algolia apu key
This commit is contained in:
1 parent
f76aa816a5
commit
15161bb0e9
6 files changed
+16
-14
No files matched your search
@@ -59,13 +59,9 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
`gatsby-plugin-theme-ui`,
|
`gatsby-plugin-theme-ui`,
|
||||||
{
|
{
|
||||||
resolve: `gatsby-plugin-algolia-docsearch`,
|
resolve: `gatsby-plugin-env-variables`,
|
||||||
options: {
|
options: {
|
||||||
appId: process.env.ALGOLIA_APP_ID || "temp",
|
allowList: ["ALGOLIA_API_KEY"],
|
||||||
apiKey: process.env.ALGOLIA_API_KEY || "temp", // required
|
|
||||||
indexName: "medusa-commerce", // required
|
|
||||||
inputSelector: "#algolia-doc-search", // required
|
|
||||||
debug: false, // (bool) Optional. Default `false`
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
// `gatsby-plugin-preact`,
|
// `gatsby-plugin-preact`,
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
"gatsby-plugin-algolia-docsearch": "^1.0.5",
|
"gatsby-plugin-algolia-docsearch": "^1.0.5",
|
||||||
"gatsby-plugin-anchor-links": "^1.1.1",
|
"gatsby-plugin-anchor-links": "^1.1.1",
|
||||||
"gatsby-plugin-emotion": "^5.0.0",
|
"gatsby-plugin-emotion": "^5.0.0",
|
||||||
|
"gatsby-plugin-env-variables": "^2.1.0",
|
||||||
"gatsby-plugin-preact": "^5.9.0",
|
"gatsby-plugin-preact": "^5.9.0",
|
||||||
"gatsby-plugin-react-helmet": "^3.3.12",
|
"gatsby-plugin-react-helmet": "^3.3.12",
|
||||||
"gatsby-plugin-theme-ui": "^0.10.1",
|
"gatsby-plugin-theme-ui": "^0.10.1",
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ const Section = ({ data }) => {
|
|||||||
}, [isInView])
|
}, [isInView])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<section
|
<main
|
||||||
ref={sectionRef}
|
ref={sectionRef}
|
||||||
id={convertToKebabCase(section.section_name)}
|
id={convertToKebabCase(section.section_name)}
|
||||||
className="DocSearch-content"
|
className="DocSearch-content"
|
||||||
@@ -200,7 +200,7 @@ const Section = ({ data }) => {
|
|||||||
)}
|
)}
|
||||||
</Flex>
|
</Flex>
|
||||||
</Box>
|
</Box>
|
||||||
</section>
|
</main>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,12 +2,10 @@ import React from "react"
|
|||||||
import { DocSearch } from "@docsearch/react"
|
import { DocSearch } from "@docsearch/react"
|
||||||
import "../../medusa-plugin-themes/docsearch/theme.css"
|
import "../../medusa-plugin-themes/docsearch/theme.css"
|
||||||
|
|
||||||
const algoliaApiKey =
|
const algoliaApiKey = process.env.ALGOLIA_API_KEY || "temp"
|
||||||
process.env.ALGOLIA_API_KEY || "25626fae796133dc1e734c6bcaaeac3c" //second opt is for testing purposes
|
|
||||||
const algoliaIndexName = process.env.ALGOLIA_API_KEY || "docsearch"
|
|
||||||
|
|
||||||
const Search = () => {
|
const Search = () => {
|
||||||
return <DocSearch apiKey={algoliaApiKey} indexName={algoliaIndexName} />
|
return <DocSearch apiKey={algoliaApiKey} indexName="medusa-commerce" />
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Search
|
export default Search
|
||||||
@@ -95,6 +95,9 @@ const Topbar = ({ data, api }) => {
|
|||||||
<Flex
|
<Flex
|
||||||
sx={{
|
sx={{
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
|
maxWidth: "400px",
|
||||||
|
flexGrow: "1",
|
||||||
|
justifyContent: "flex-end",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Link variant="topbar" mr={3} href="https://docs.medusa-commerce.com">
|
<Link variant="topbar" mr={3} href="https://docs.medusa-commerce.com">
|
||||||
@@ -109,8 +112,7 @@ const Topbar = ({ data, api }) => {
|
|||||||
>
|
>
|
||||||
<GitHub />
|
<GitHub />
|
||||||
</Link>
|
</Link>
|
||||||
{/* Re-add once indexing has been fine tuned */}
|
<Search />
|
||||||
{/* <Search /> */}
|
|
||||||
</Flex>
|
</Flex>
|
||||||
</Flex>
|
</Flex>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -5446,6 +5446,11 @@ gatsby-plugin-emotion@^5.0.0:
|
|||||||
"@babel/runtime" "^7.11.2"
|
"@babel/runtime" "^7.11.2"
|
||||||
"@emotion/babel-preset-css-prop" "^11.0.0"
|
"@emotion/babel-preset-css-prop" "^11.0.0"
|
||||||
|
|
||||||
|
gatsby-plugin-env-variables@^2.1.0:
|
||||||
|
version "2.1.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/gatsby-plugin-env-variables/-/gatsby-plugin-env-variables-2.1.0.tgz#6204113d214e8854cbc9f6e90c6650c7035e277c"
|
||||||
|
integrity sha512-TNApeosvOcDxOoxZuzJ3rK4rbR2Fvzvweszn22U+z7bVtZ09G8/MtZg14l3HPXQBwqWjsWJH+PrRP+Z+7W7N/A==
|
||||||
|
|
||||||
gatsby-plugin-page-creator@^3.12.0:
|
gatsby-plugin-page-creator@^3.12.0:
|
||||||
version "3.12.0"
|
version "3.12.0"
|
||||||
resolved "https://registry.yarnpkg.com/gatsby-plugin-page-creator/-/gatsby-plugin-page-creator-3.12.0.tgz#79a74354e1e5a1400d7721aba5f6127d2de187b2"
|
resolved "https://registry.yarnpkg.com/gatsby-plugin-page-creator/-/gatsby-plugin-page-creator-3.12.0.tgz#79a74354e1e5a1400d7721aba5f6127d2de187b2"
|
||||||
|
|||||||
Reference in new issue
Block a user