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 }) => {
|
const ResultList = ({ searchResults }) => {
|
||||||
return (
|
return (
|
||||||
<div style={{ maxHeight: '100%' }}>
|
<div style={{ maxHeight: '100%' }}>
|
||||||
<div>
|
<div>Total results found: {searchResults.length}</div>
|
||||||
Total results found: {searchResults.length} [Searched from Tutorials and
|
|
||||||
Core Concepts]
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<List style={{ maxHeight: '100%' }}>
|
<List style={{ maxHeight: '100%' }}>
|
||||||
|
@ -10,7 +10,9 @@ import PropTypes from 'prop-types'
|
|||||||
const SearchComponent = ({ location }) => {
|
const SearchComponent = ({ location }) => {
|
||||||
const data = useStaticQuery(graphql`
|
const data = useStaticQuery(graphql`
|
||||||
query {
|
query {
|
||||||
allMarkdownRemark(filter: { fileAbsolutePath: { regex: "/content/" } }) {
|
allMarkdownRemark(
|
||||||
|
filter: { fileAbsolutePath: { regex: "/content/|/markdowns/" } }
|
||||||
|
) {
|
||||||
edges {
|
edges {
|
||||||
node {
|
node {
|
||||||
fields {
|
fields {
|
||||||
@ -20,6 +22,9 @@ const SearchComponent = ({ location }) => {
|
|||||||
frontmatter {
|
frontmatter {
|
||||||
title
|
title
|
||||||
description
|
description
|
||||||
|
app
|
||||||
|
slug
|
||||||
|
module
|
||||||
}
|
}
|
||||||
id
|
id
|
||||||
plainText
|
plainText
|
||||||
@ -28,20 +33,33 @@ const SearchComponent = ({ location }) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
`)
|
`)
|
||||||
|
|
||||||
const searchableData = data.allMarkdownRemark.edges.map(({ node }) => {
|
const searchableData = data.allMarkdownRemark.edges.map(({ node }) => {
|
||||||
var section = 'Concepts'
|
var { slug } = node.fields
|
||||||
if (node.fields.slug.startsWith('/tutorials')) section = 'Tutorials'
|
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 {
|
return {
|
||||||
title: node.frontmatter.title,
|
title: node.frontmatter.title,
|
||||||
description: node.frontmatter.description,
|
description: node.frontmatter.description,
|
||||||
slug: node.fields.slug,
|
|
||||||
id: node.id,
|
id: node.id,
|
||||||
text: node.plainText,
|
text: node.plainText,
|
||||||
section: section
|
slug,
|
||||||
|
section
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Layout location={location}>
|
<Layout location={location}>
|
||||||
<HeaderSection title="Search" />
|
<HeaderSection title="Search" />
|
||||||
|
Loading…
Reference in New Issue
Block a user