mirror of
https://github.com/oceanprotocol/docs.git
synced 2024-11-26 19:49:26 +01:00
Issue-545: Add search button on home page
This commit is contained in:
parent
a0d1c77f48
commit
aac6849bc5
@ -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) => {
|
).then(async (result) => {
|
||||||
@ -151,9 +133,6 @@ exports.createPages = ({ graphql, actions }) => {
|
|||||||
|
|
||||||
await createDeploymentsPage(createPage)
|
await createDeploymentsPage(createPage)
|
||||||
|
|
||||||
const searchContext = result.data.searchContext.edges
|
|
||||||
await createSearchPage(createPage, searchContext)
|
|
||||||
|
|
||||||
// API: ocean.js
|
// API: ocean.js
|
||||||
const lastRelease =
|
const lastRelease =
|
||||||
result.data.oceanJs.repository.releases.edges.filter(
|
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
|
// Create pages from TypeDoc json files
|
||||||
//
|
//
|
||||||
|
@ -3,7 +3,7 @@ import { StaticQuery, graphql } from 'gatsby'
|
|||||||
import { ReactComponent as Logo } from '@oceanprotocol/art/logo/logo.svg'
|
import { ReactComponent as Logo } from '@oceanprotocol/art/logo/logo.svg'
|
||||||
import Content from '../components/Content'
|
import Content from '../components/Content'
|
||||||
import styles from './HeaderHome.module.scss'
|
import styles from './HeaderHome.module.scss'
|
||||||
import SearchComponent from './Search/SearchComponent'
|
|
||||||
const HeaderHome = () => (
|
const HeaderHome = () => (
|
||||||
<StaticQuery
|
<StaticQuery
|
||||||
query={graphql`
|
query={graphql`
|
||||||
@ -25,7 +25,6 @@ const HeaderHome = () => (
|
|||||||
<Logo className={styles.headerLogo} />
|
<Logo className={styles.headerLogo} />
|
||||||
<h1 className={styles.headerTitle}>{siteTitle}</h1>
|
<h1 className={styles.headerTitle}>{siteTitle}</h1>
|
||||||
<p className={styles.headerDescription}>{siteDescription}</p>
|
<p className={styles.headerDescription}>{siteDescription}</p>
|
||||||
<SearchComponent />
|
|
||||||
</Content>
|
</Content>
|
||||||
</header>
|
</header>
|
||||||
)
|
)
|
||||||
|
@ -89,7 +89,12 @@ const SearchClient = ({ searchableData }) => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<Button onClick={handleOpen} startIcon={<SearchIcon />}>
|
<Button
|
||||||
|
variant="outlined"
|
||||||
|
onClick={handleOpen}
|
||||||
|
disableRipple
|
||||||
|
startIcon={<SearchIcon />}
|
||||||
|
>
|
||||||
Search
|
Search
|
||||||
</Button>
|
</Button>
|
||||||
<Modal
|
<Modal
|
||||||
|
@ -1,14 +1,31 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
|
|
||||||
import { graphql } from 'gatsby'
|
import { useStaticQuery, graphql } from 'gatsby'
|
||||||
import PropTypes from 'prop-types'
|
|
||||||
|
|
||||||
import SearchClient from './SearchClient'
|
import SearchClient from './SearchClient'
|
||||||
|
|
||||||
const SearchComponent = ({ data, pageContext }) => {
|
const SearchComponent = () => {
|
||||||
console.log('data', data)
|
const data = useStaticQuery(graphql`
|
||||||
const { searchData } = pageContext
|
query {
|
||||||
const searchableData = searchData.map(({ node }) => {
|
allMarkdownRemark(filter: { fileAbsolutePath: { regex: "/content/" } }) {
|
||||||
|
edges {
|
||||||
|
node {
|
||||||
|
fields {
|
||||||
|
slug
|
||||||
|
section
|
||||||
|
}
|
||||||
|
frontmatter {
|
||||||
|
title
|
||||||
|
description
|
||||||
|
}
|
||||||
|
id
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`)
|
||||||
|
|
||||||
|
const searchableData = data.allMarkdownRemark.edges.map(({ node }) => {
|
||||||
return {
|
return {
|
||||||
title: node.frontmatter.title,
|
title: node.frontmatter.title,
|
||||||
description: node.frontmatter.description,
|
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
|
export default SearchComponent
|
||||||
|
@ -9,6 +9,7 @@ import HeaderHome from '../components/HeaderHome'
|
|||||||
import Repositories from '../components/Repositories'
|
import Repositories from '../components/Repositories'
|
||||||
import { ReactComponent as Arrow } from '../images/arrow.svg'
|
import { ReactComponent as Arrow } from '../images/arrow.svg'
|
||||||
import styles from './index.module.scss'
|
import styles from './index.module.scss'
|
||||||
|
import SearchComponent from '../components/Search/SearchComponent'
|
||||||
|
|
||||||
const SectionBox = ({ to, children, ...props }) =>
|
const SectionBox = ({ to, children, ...props }) =>
|
||||||
to ? (
|
to ? (
|
||||||
@ -66,7 +67,9 @@ const IndexPage = ({ data, location }) => (
|
|||||||
</li>
|
</li>
|
||||||
))}
|
))}
|
||||||
</ul>
|
</ul>
|
||||||
|
<div className={styles.searchButton}>
|
||||||
|
<SearchComponent />
|
||||||
|
</div>
|
||||||
<Repositories />
|
<Repositories />
|
||||||
</Content>
|
</Content>
|
||||||
</Layout>
|
</Layout>
|
||||||
|
@ -112,3 +112,8 @@
|
|||||||
transition: transform 0.2s ease-out;
|
transition: transform 0.2s ease-out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.searchButton {
|
||||||
|
margin-top: 20px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user