diff --git a/gatsby-node.js b/gatsby-node.js index 721146a7..f0823b61 100755 --- a/gatsby-node.js +++ b/gatsby-node.js @@ -103,24 +103,6 @@ exports.createPages = ({ graphql, actions }) => { } } } - - searchContext: allMarkdownRemark( - filter: { fileAbsolutePath: { regex: "/content/" } } - ) { - edges { - node { - fields { - slug - section - } - frontmatter { - title - description - } - id - } - } - } } ` ).then(async (result) => { @@ -151,9 +133,6 @@ exports.createPages = ({ graphql, actions }) => { await createDeploymentsPage(createPage) - const searchContext = result.data.searchContext.edges - await createSearchPage(createPage, searchContext) - // API: ocean.js const lastRelease = result.data.oceanJs.repository.releases.edges.filter( @@ -209,18 +188,6 @@ const createDeploymentsPage = async (createPage) => { }) } -const createSearchPage = async (createPage, searchContext) => { - const template = path.resolve('./src/components/Search/SearchComponent.jsx') - const slug = `/concepts/search/` - - createPage({ - path: slug, - component: template, - context: { - searchData: searchContext - } - }) -} // // Create pages from TypeDoc json files // diff --git a/src/components/HeaderHome.jsx b/src/components/HeaderHome.jsx index 5895c5cb..2ad511fa 100644 --- a/src/components/HeaderHome.jsx +++ b/src/components/HeaderHome.jsx @@ -3,7 +3,7 @@ import { StaticQuery, graphql } from 'gatsby' import { ReactComponent as Logo } from '@oceanprotocol/art/logo/logo.svg' import Content from '../components/Content' import styles from './HeaderHome.module.scss' -import SearchComponent from './Search/SearchComponent' + const HeaderHome = () => ( (

{siteTitle}

{siteDescription}

- ) diff --git a/src/components/Search/SearchClient.jsx b/src/components/Search/SearchClient.jsx index d08fea5e..35ee6af5 100644 --- a/src/components/Search/SearchClient.jsx +++ b/src/components/Search/SearchClient.jsx @@ -89,7 +89,12 @@ const SearchClient = ({ searchableData }) => { return (
- { - console.log('data', data) - const { searchData } = pageContext - const searchableData = searchData.map(({ node }) => { +const SearchComponent = () => { + const data = useStaticQuery(graphql` + query { + allMarkdownRemark(filter: { fileAbsolutePath: { regex: "/content/" } }) { + edges { + node { + fields { + slug + section + } + frontmatter { + title + description + } + id + } + } + } + } + `) + + const searchableData = data.allMarkdownRemark.edges.map(({ node }) => { return { title: node.frontmatter.title, description: node.frontmatter.description, @@ -23,29 +40,4 @@ const SearchComponent = ({ data, pageContext }) => { ) } -SearchComponent.propTypes = { - pageContext: PropTypes.object, - data: PropTypes.object -} - -export const SearchComponentQuery = graphql` - query { - allMarkdownRemark(filter: { fileAbsolutePath: { regex: "/content/" } }) { - edges { - node { - fields { - slug - section - } - frontmatter { - title - description - } - id - } - } - } - } -` - export default SearchComponent diff --git a/src/pages/index.jsx b/src/pages/index.jsx index 425a0bdf..2822a06f 100755 --- a/src/pages/index.jsx +++ b/src/pages/index.jsx @@ -9,6 +9,7 @@ import HeaderHome from '../components/HeaderHome' import Repositories from '../components/Repositories' import { ReactComponent as Arrow } from '../images/arrow.svg' import styles from './index.module.scss' +import SearchComponent from '../components/Search/SearchComponent' const SectionBox = ({ to, children, ...props }) => to ? ( @@ -66,7 +67,9 @@ const IndexPage = ({ data, location }) => ( ))} - +
+ +
diff --git a/src/pages/index.module.scss b/src/pages/index.module.scss index 95e98992..4b556f2d 100644 --- a/src/pages/index.module.scss +++ b/src/pages/index.module.scss @@ -112,3 +112,8 @@ transition: transform 0.2s ease-out; } } + +.searchButton { + margin-top: 20px; + text-align: center; +} \ No newline at end of file