mirror of
https://github.com/oceanprotocol/docs.git
synced 2024-11-26 19:49:26 +01:00
Merge pull request #777 from oceanprotocol/issue-776-add-py-modules-to-search-index
Issue-#776: Add py module docs to search index
This commit is contained in:
commit
4b6e47e1b4
@ -128,10 +128,7 @@ SearchClient.propTypes = {
|
||||
const ResultList = ({ searchResults }) => {
|
||||
return (
|
||||
<div style={{ maxHeight: '100%' }}>
|
||||
<div>
|
||||
Total results found: {searchResults.length} [Searched from Tutorials and
|
||||
Core Concepts]
|
||||
</div>
|
||||
<div>Total results found: {searchResults.length}</div>
|
||||
|
||||
<div>
|
||||
<List style={{ maxHeight: '100%' }}>
|
||||
|
@ -10,7 +10,9 @@ import PropTypes from 'prop-types'
|
||||
const SearchComponent = ({ location }) => {
|
||||
const data = useStaticQuery(graphql`
|
||||
query {
|
||||
allMarkdownRemark(filter: { fileAbsolutePath: { regex: "/content/" } }) {
|
||||
allMarkdownRemark(
|
||||
filter: { fileAbsolutePath: { regex: "/content/|/markdowns/" } }
|
||||
) {
|
||||
edges {
|
||||
node {
|
||||
fields {
|
||||
@ -20,6 +22,9 @@ const SearchComponent = ({ location }) => {
|
||||
frontmatter {
|
||||
title
|
||||
description
|
||||
app
|
||||
slug
|
||||
module
|
||||
}
|
||||
id
|
||||
plainText
|
||||
@ -28,20 +33,33 @@ const SearchComponent = ({ location }) => {
|
||||
}
|
||||
}
|
||||
`)
|
||||
|
||||
const searchableData = data.allMarkdownRemark.edges.map(({ node }) => {
|
||||
var section = 'Concepts'
|
||||
if (node.fields.slug.startsWith('/tutorials')) section = 'Tutorials'
|
||||
var { slug } = node.fields
|
||||
var section = null
|
||||
|
||||
if (node.fields.slug.startsWith('/tutorials')) {
|
||||
section = 'Tutorials'
|
||||
} else if (node.fields.slug.startsWith('/concepts')) {
|
||||
section = 'Core concepts'
|
||||
} else if (node.frontmatter.module) {
|
||||
// This is for adding py module docs to index
|
||||
slug = `/references/read-the-docs/${node.frontmatter.app.replace(
|
||||
'.',
|
||||
'-'
|
||||
)}/${node.frontmatter.slug}`
|
||||
section = `API References [${node.frontmatter.app}]`
|
||||
}
|
||||
|
||||
return {
|
||||
title: node.frontmatter.title,
|
||||
description: node.frontmatter.description,
|
||||
slug: node.fields.slug,
|
||||
id: node.id,
|
||||
text: node.plainText,
|
||||
section: section
|
||||
slug,
|
||||
section
|
||||
}
|
||||
})
|
||||
|
||||
return (
|
||||
<Layout location={location}>
|
||||
<HeaderSection title="Search" />
|
||||
|
Loading…
Reference in New Issue
Block a user